Hello everyone, my first time here and so far very impressed with the contents of this board.
I've run into a problem and hope someone can tell me where I got sidetracked.
Facts: on a form I have four comboxes and two text boxes from which the user will select/input and then run the report based on their selections. The user does NOT have to select from every field. ie. user has choice to input or select from one, two, three, etc... or all fields.
Problem(s): (I may be wrong here !!) I figure there are about 55 different combinations with 6 fields. How do I write this code so I don't have to rewrite it 55 different ways? I tried using the "Not IsNull" and found that you can't use it here in this fashion (whyyyyyy???)
strSQL2 = "SELECT * FROM Freight WHERE Carrier = '" & Me!cboCarrier & "' AND Origin = '" & Me!cboOrigin & "' OR Carrier = '" & Me!cboCarrier & "' OR Origin = '" & Me!cboOrigin & "'"
The above should give me the option of selecting the following:
1) get me all records where value is equal cboCarrier and value is also equal to cboOrigin. OR
2) get me all records where value is equal to cboCarrier OR
3) get me all records where value is equal to cboOrigin
Supposing I entered a value of "Yellow Freight" for carrier and "New York" for origin and then run the report, I get ALL Yellow Freight records as well as ALL "New York" records. What I really want is ALL records having both Yellow Freight and New York.
And if I only entered Yellow Freight, then I should only get results equal to Yellow Freight.
Any help will be much appreciated.
Many thanks in advance.
I've run into a problem and hope someone can tell me where I got sidetracked.
Facts: on a form I have four comboxes and two text boxes from which the user will select/input and then run the report based on their selections. The user does NOT have to select from every field. ie. user has choice to input or select from one, two, three, etc... or all fields.
Problem(s): (I may be wrong here !!) I figure there are about 55 different combinations with 6 fields. How do I write this code so I don't have to rewrite it 55 different ways? I tried using the "Not IsNull" and found that you can't use it here in this fashion (whyyyyyy???)
strSQL2 = "SELECT * FROM Freight WHERE Carrier = '" & Me!cboCarrier & "' AND Origin = '" & Me!cboOrigin & "' OR Carrier = '" & Me!cboCarrier & "' OR Origin = '" & Me!cboOrigin & "'"
The above should give me the option of selecting the following:
1) get me all records where value is equal cboCarrier and value is also equal to cboOrigin. OR
2) get me all records where value is equal to cboCarrier OR
3) get me all records where value is equal to cboOrigin
Supposing I entered a value of "Yellow Freight" for carrier and "New York" for origin and then run the report, I get ALL Yellow Freight records as well as ALL "New York" records. What I really want is ALL records having both Yellow Freight and New York.
And if I only entered Yellow Freight, then I should only get results equal to Yellow Freight.
Any help will be much appreciated.
Many thanks in advance.