Need help using the INCSTR function

Demonic240Demonic240 Member Posts: 65
I have code behind a button on a form that is supposed to create a Vendor Invoice No. each time it is run. The invoice no. is based on the WORKDATE. At the top of my code for my button I have this:
STR:=DELCHR('EXPRT'+FORMAT(WORKDATE)+'-1','=','/');
PH.SETFILTER("Buy-from Vendor No.",EmployeeExpense3."Employee No.");
PH.SETFILTER("Posting Date",FORMAT(WORKDATE));
IF PH.FINDFIRST THEN
  STR:=INCSTR(STR);

The DELCHR works fine, but for some reason I can not figure out how to get the number to change each time the button is run. Please help.

Comments

  • SavatageSavatage Member Posts: 7,142
  • Demonic240Demonic240 Member Posts: 65
    Thanks, I looked into that thread and experimented with it. I don't think it's exactly what I'm looking for.
  • ufukufuk Member Posts: 514
    something like?

    i := -1;
    PH.SETFILTER("Buy-from Vendor No.",EmployeeExpense3."Employee No.");
    PH.SETFILTER("Posting Date",FORMAT(WORKDATE));
    IF PH.FINDFIRST THEN BEGIN
    i += 1;
    STR:=DELCHR('EXPRT'+FORMAT(WORKDATE)+FORMAT(i),'=','/');
    END;
    Ufuk Asci
    Pargesoft
  • ufukufuk Member Posts: 514
    something like?

    i := -1;
    PH.SETFILTER("Buy-from Vendor No.",EmployeeExpense3."Employee No.");
    PH.SETFILTER("Posting Date",FORMAT(WORKDATE));
    IF PH.FINDFIRST THEN BEGIN
    i += 1;
    STR:=DELCHR('EXPRT'+FORMAT(WORKDATE)+FORMAT(i),'=','/');
    END;
    Ufuk Asci
    Pargesoft
  • Demonic240Demonic240 Member Posts: 65
    I think what I need to do is find a way to check another record for the last string. If it's there then it needs to add 1 to the end of the new string. The other idea I had was storing the number in the string somehow on the table. But then how could I make it start over on the next workdate?
  • Demonic240Demonic240 Member Posts: 65
    I think this might be closer to what I need but it's still not working.
        PH.SETFILTER("Buy-from Vendor No.",EmployeeExpense3."Employee No.");
        PH.SETFILTER("Posting Date",FORMAT(WORKDATE));
        IF PH.FINDLAST THEN BEGIN
          STR:=PH."Vendor Invoice No.";
          STR:=INCSTR(STR)
        END;
    

    Edit:

    Ok this is working, however I have to run it twice. The first time it tries to use the previous STR. The second time it uses the next one.
Sign In or Register to comment.