If statement in Where Clause of SQL?

B

BlueWolverine

Hello
Ms Access 2003 on XP Pro.

I want to put an if statement in my where clause.

where
if Checkbox = true then
t.A=f.A AND t.b=f.b
else
t.A=f.A OR t.b=f.b
endif

1) Does this work?
2) Is this more efficient than having the vba pick between two different
queries?

Since I want to do this to two daisy chained queries, I would actually have
to write four queries for the vba method above. Don't want to do that.

Thanks.
 
B

BlueWolverine

worked like a charm.
--
BlueWolverine
MSE - Mech. Eng.
Go BLUE!


Stefan Hoffmann said:
hi,
I want to put an if statement in my where clause.

where
if Checkbox = true then
t.A=f.A AND t.b=f.b
else
t.A=f.A OR t.b=f.b
endif

1) Does this work?
Yup, try this:

WHERE
(Form![yourForm].Form![yourCheckbox] AND t.A=f.A AND t.b=f.b)
OR
(NOT Form![yourForm].Form![yourCheckbox] AND (t.A=f.A OR t.b=f.b))

Check the condition carefully, it maybe not correct, even if I think it
should.
2) Is this more efficient than having the vba pick between two different
queries?
Maybe. This depends on whether the optimizer can handle the closed
expression or not.


mfG
--> stefan <--
 
Top