Searching For A Sub string in a String

Five
Member Posts: 32
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 :?
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 ....
0
Comments
-
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, Denmark0 -
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
FiveCompile and then Recompile ....0 -
You do not have to show the field to filter on it...So I would choose to "hide" the field...Regards,
Henrik Frederiksen, Denmark0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions