If Then??

HOJU15

Registered User.
Local time
Today, 00:33
Joined
Feb 7, 2003
Messages
12
I have 5 fields in a table that is either blank or contains a integer.
call them fields A,B,C,D,E

When I run my query i want the user to type in a number for A,B,C,D,E or leave it blank. If the user leaves the parameter blank I want the system to return all values for that field including null ones. BUT if the user types in a number I want the query to return recoreds that match that value

if parameter is blank than return all records, if parameter equals "5" return all records = 5

What is the SQL TO DO THIS!
 
SELECT *
FROM [TableName]
WHERE IIf([Enter a number] is null, True, A=[Enter a number] and B=[Enter a number] and C=[Enter a number] and D=[Enter a number] and E=[Enter a number]);
 
Last edited:

Users who are viewing this thread

Back
Top Bottom