Results 1 to 6 of 6
  1. #1
    BusDriver3 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    46

    Query Value Not Required

    Hello There,



    I am trying to create a "Form" that contains several Combo-Boxes that will act as the criteria to feed a query. In the query I am using the following criteria for the Form values to feed the query
    Code:
    [Forms]![Report Generator 2]![Directorate]
    This works when I select the values for each and every Combo-Box... But...

    What I would like to do is make some of the Combo-Box values "Not Required" and still have the query work... Is this possible?

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    your query needs to account for a null so something like

    [Forms]![Report Generator 2]![Directorate] OR [Forms]![Report Generator 2]![Directorate] IS NULL

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Wouldn't an Nz() function or IIf and IsNull() help to provide the appropriate data type to the parameter?

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    alternatives could be

    WHERE myfield=nz([Forms]![Report Generator 2]![Directorate],myfield)

    or

    WHERE myfield=iif(isnull([Forms]![Report Generator 2]![Directorate]),myfield,[Forms]![Report Generator 2]![Directorate])

    or

    WHERE myfield=iif([Forms]![Report Generator 2]![Directorate] is null,myfield,[Forms]![Report Generator 2]![Directorate])

    Not tested on a large dataset but all involve using one or more functions which will generally slow the performance of the query

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    OK, I am starting to imagine how #2 could be applied.

  6. #6
    BusDriver3 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    46
    Thanks for the speedy responses! This forum is GREAT! I didn't have much luck with the examples above, but you guys made me rethink my objectives... I am going to use just three Combo-Boxes that are the most relevant to feed a report that contains the other ancillary details. Again thanks!

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

Similar Threads

  1. Query Required to count Data
    By Mubashar in forum Queries
    Replies: 2
    Last Post: 03-08-2016, 04:50 AM
  2. Help required with a Single Record Query
    By thompjas in forum Queries
    Replies: 10
    Last Post: 03-03-2015, 04:03 AM
  3. Replies: 1
    Last Post: 02-12-2013, 09:12 AM
  4. Urgent Access query help required
    By aty01 in forum Queries
    Replies: 9
    Last Post: 05-23-2012, 12:57 PM
  5. Query Help Required
    By rivergum_23 in forum Queries
    Replies: 6
    Last Post: 04-28-2012, 02:07 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