Changeable Criteria Expressions

lledar

Research Analyst
Local time
Today, 16:25
Joined
Mar 8, 2005
Messages
10
In the following code I would like to add a user input criteria expression selectible through a form combobox with three option to select from And/Or/Not

Like "*" & [Forms]![Test]![AbstractBox] & "*"
And Like "*" & [Forms]![Test]![AbstractBox2] & "*"
And Like "*" & [Forms]![Test]![AbstractBox3] & "*"

I have tried to do the following where I replace the And expression with the value of the combobox with the selectible options.

Like "*" & [Forms]![Test]![AbstractBox] & "*"
[Forms]![Test]![Criteriabox1] Like "*" & [Forms]![Test]![AbstractBox2] & "*"
[Forms]![Test]![Criteriabox2] Like "*" & [Forms]![Test]![AbstractBox3] & "*"

I get the following error:
Microsoft Office Access
The expression you have entered contains invalid syntax.
You may have entered an operand without an operator.

What should be the correct syntax to perform this option?
 
Where are you using the expression (SQL from VBA or query object)?
 
Using it within the actually query itself in the Criteria
 
Unfortunately you can't use that type of concatenated expression in a query.

My suggestion would be to make a separate query for each condition (And/Or/Not) and then just use the appropriate query based on the selection.
 
Last edited:
Thanks a bunch Pat. wasnt sure if what I was doing was possible without having to go and actually build the code. I have very used VB so I am teaching myself as I go. Again thanks for your time
 

Users who are viewing this thread

Back
Top Bottom