Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Joliette, Quebec, Canada
    Posts
    290
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Sex in the query (2000)

    I have a data base of worker

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Sex in the query (2000)

    Remove the criteria from the Sex field. In the first empty column of the query grid, type Forms!SelectionForm!cbo_Sex in the Field: row, and type [Sex] Or Is Null in the Criteria: row (assuming that the field is named Sex). This means that the combo box on the field must match the Sex field, or be empty. If necessary, you can repeat this for the accident district and residence district fields.

  3. #3
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Joliette, Quebec, Canada
    Posts
    290
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Re: Sex in the query (2000)

    Thank for the suggestion and yes i need it for the resident district number and all other fields . I added a new column, then added the combobox's full name and added the variable name or is null to the criteria box and it did not work. There is a chance I am very dumb.

    I there not a way to tell the query if the form combo box sex is null then select all.
    Or how can i add the equivalent to "all" to my combo box values <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

    Richard

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Sex in the query (2000)

    Take a look at the attached very simple sample database (Access 97, zipped, you'll have to download, unzip and convert it).
    The form frmSelect contains combo boxes for district and sex, and a command button that opens a continuous form frmData based on a query qryDataSelect that uses the combo boxes on frmSelect as criteria in the way I sketched in my previous reply. Look at the design of the query. The SQL for this query (with some superfluous parantheses removed) is:

    SELECT *
    FROM tblData
    WHERE ([Forms]![frmSelect]![cboDistrict]=[District] Or [Forms]![frmSelect]![cboDistrict] Is Null) AND ([Forms]![frmSelect]![cboSex]=[Sex] Or [Forms]![frmSelect]![cboSex] Is Null);

    (as you see, I have created a simpler situation than yours; it is meant to illustrate the method only, not as a complete simulation of your database)

    If this doesn't help you, pleas provide more details of the query that doesn't work the way you want (for instance, post the SQL.)
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •