query syntax or design question ...

  • Thread starter Thread starter dannie
  • Start date Start date
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 the 12 areas that are options 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.
 
I finally figured it out !!!! If anyone wants to know the code used it was

WHERE IIf((Forms![Main
Form]!cmbArea<>"ALL"),((InspectionsDI.Area)=Forms![Main
Form]!cmbArea),InspectionsDI.[Manhole Number (12)]<>"")
 
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 the 12 areas that are options 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.

I'm pretty sure this question got answered two or three times yesterday... it
seems that the flaky webpage interface is eating posts again. GRUMP.

If you see this, try

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";
 
Back
Top