Searching For A Sub string in a String

FiveFive Member Posts: 32
edited 2004-02-26 in Navision Attain
Hello All,

I have a problem in that if i have a range of Itemcodes from "1000 to 9000" for example.

Now on a form say a user enters "1170" in a text box.I want to be able to collect all Itemcodes that have "11" as the start of the code.So these would be "1110,1120,1135,1148" etc and it must then populate the relevant fields.

Can this be done?

Here is an attempt by me

IF ItemCode <> '' THEN BEGIN //ItemCode is the source expr'sion of TB
NewItemCode:= ItemCode;
INIT;
NewItemCode:=DELSTR(ItemCode,3,2);
//sam:= STRPOS(ItemCode,NewItemCode); found this by using f1
// Item.SETFILTER("No.",'<=%1',ItemCode); this evrything below 1170
IF Item.FIND('-') THEN
REPEAT
IF FirstPos=SecondPos THEN BEGIN
"Table Entry No.":=NextEntryNo;
"Item No.":=Item."No.";
"Old price":=Item."Unit Cost";
Item.CALCFIELDS(Inventory);
Quantity := Item.Inventory ;
"Person Amending" := USERID;
INSERT;
NextEntryNo:= NextEntryNo +1;
END;
UNTIL Item.NEXT=0;
END;


thanks for the help
Regards
Five :?
Compile and then Recompile ....

Comments

  • fredefrede Member Posts: 80
    To do this the easiest way add a field to the Item-table consisting of the Items first 2 digits.

    Then You could filter on this, nice and easy...Maybe using the field "Statistics Group" or a new field...?[/quote]
    Regards,

    Henrik Frederiksen, Denmark
  • FiveFive Member Posts: 32
    Hi Henrik,

    Thanks for the idea.But will the user be able to see this on the form he is interacting with?

    The idea is that the user enters the itemcode and all products that begin with this code appear in the grid below.

    Will try what you say ....but still not sure

    cheers
    Five
    Compile and then Recompile ....
  • fredefrede Member Posts: 80
    You do not have to show the field to filter on it...So I would choose to "hide" the field...
    Regards,

    Henrik Frederiksen, Denmark
Sign In or Register to comment.