Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Instr() function

Status
Not open for further replies.

dridgeway

Technical User
Jun 3, 2003
16
I have a parameter query that prompts:
[Enter Freight Terms]

User needs to be able to enter single or multiple values (seperated by commas)

Freight Terms is a 3 character field with only 3 different values: P, PA & C - however if I enter PA, I receive all the P's and the PA's...how can I avoid this? Both have the letter P as the starting character.

Here's my SQL statement:
SELECT DPL.LOAD, DPL.PRECOL3RD
FROM DPL
WHERE (((InStr([Enter Freight Terms],[DPL].[PRECOL3RD]))
Is Null Or (InStr([Enter Freight Terms],[DPL].[PRECOL3RD]))>0));
 
Couldn't it just be:
Code:
SELECT DPL.LOAD, DPL.PRECOL3RD
FROM DPL
WHERE DPL.PRECOL3RD = [Enter Freight Terms]


 
I need the user to be able to select multiples, P & PA, or P & C, C & PA....etc.
 
All the possible variations make it virtually impossible to code inline in the SQL statement.

I would make a multi-select listbox with C, P, and PA, then build the WHERE clause from what was selected in the listbox.

 
I ended up doing this:

((InStr(" & strFreight & ",format([DPL].[PRECOL3RD],'!@@@')))>0 Or (InStr(" & strFreight & ",format([DPL].[PRECOL3RD],'!@@@'))) Is Null)

StrFreight is just an entry box on a form - but works with miltiples now with commas

Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top