Results 1 to 2 of 2
  1. #1
    cowboy is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    291

    query syntax or design help ....

    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 just tried

    WHERE
    If (Forms![Main Form]!cmbArea <> "ALL") then
    ((InspectionsDI.Area)=Forms![Main Form]!cmbArea)
    end if

    and it gave me a syntax error (missing operator)

  2. #2
    cowboy is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    291
    I got it too work !!!! wahoo..
    for anyone interested in knowing the syntax it ended up being

    WHERE IIf((Forms![Main Form]!cmbArea<>"ALL"),((InspectionsDI.Area)=Forms![Main Form]!cmbArea),InspectionsDI.[Manhole Number (12)]<>"")

Please reply to this thread with any new information or opinions.

Similar Threads

  1. quick query syntax questions
    By cowboy in forum Access
    Replies: 6
    Last Post: 02-03-2010, 06:10 PM
  2. Syntax error (comma) in query expression
    By KLynch0803 in forum Programming
    Replies: 3
    Last Post: 01-18-2010, 03:35 AM
  3. Sql Syntax Query
    By Matthieu in forum Queries
    Replies: 4
    Last Post: 12-30-2009, 09:41 AM
  4. Query Design View Takes a Long Time to Open
    By jackthedog in forum Queries
    Replies: 0
    Last Post: 12-22-2009, 03:27 PM
  5. Replies: 1
    Last Post: 10-07-2009, 07:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums