Quick Query Problem

D

dannie

PARAMETERS [Forms]![Main Form]![cmbArea] Text ( 255 );
SELECT InspectionsDI.ID,InspectionsDI.Area
FROM InspectionsDI
WHERE InspectionsDI.Area=Forms![Main Form]!cmbArea;

This code works correctly for each individual area but I also want to allow
all the records to show if Forms![Main Form]!cmbArea = "ALL"

I am not sure how to do this, I tried If statement but my syntax must have
been wrong, thanks for help.
 
K

KARL DEWEY

Try this --
PARAMETERS [Forms]![Main Form]![cmbArea] Text ( 255 );
SELECT InspectionsDI.ID,InspectionsDI.Area
FROM InspectionsDI
WHERE InspectionsDI.Area Like IIF(Forms![Main Form]!cmbArea = "All", "*",
Forms![Main Form]!cmbArea);
 
D

Duane Hookom

PARAMETERS [Forms]![Main Form]![cmbArea] Text ( 255 );
SELECT InspectionsDI.ID,InspectionsDI.Area
FROM InspectionsDI
WHERE InspectionsDI.Area=Forms![Main Form]!cmbArea OR
Forms![Main Form]!cmbArea="ALL";
 
J

John W. Vinson

This code works correctly for each individual area but I also want to allow
all the records to show if Forms![Main Form]!cmbArea = "ALL"

I am not sure how to do this, I tried If statement but my syntax must have
been wrong, thanks for help.

PARAMETERS [Forms]![Main Form]![cmbArea] Text ( 255 );
SELECT InspectionsDI.ID,InspectionsDI.Area
FROM InspectionsDI
WHERE InspectionsDI.Area=Forms![Main Form]!cmbArea
OR Forms![Main Form]!cmbArea = "All";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top