Results 1 to 9 of 9
  1. #1
    Kevo is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2011
    Location
    Kodiak, Alaska
    Posts
    86

    Help with multiple query fields....including Between/And

    Hi,
    I have read through many posts but still cant figure this out....

    I made a search form that includes
    -StartDate EndDate
    -Machine#

    (and would liek to add a few more)

    I would like the user to be able to - Enter 2 dates and have it show all records between dates - and/or enter machine# and see records associated with that machine......and a few other things (which I will worry about once I get these two to work)

    I have a query in design view that has

    LoadDate
    Between StartDate And EndDate

    Machine#

    Like Machine# &*

    But this isn't working as expected.....what am I missing.

    Here is the actual code I used....note: the field names I used above were for simplicity in explaining.....

    SELECT tblLoad.LoadID, tblLoad.LoadDate, tblLoad.AutoclaveID, tblLoad.LoadNumber, tblLoad.BI, tblLoad.[Process Challenge Device], tblLoad.[Cycle Complete], tblLoad.[Cycle Aborted]
    FROM tblLoad
    WHERE (((tblLoad.LoadDate) Between [Forms]![frmSearchMenu].[qLoadDate1] And [Forms]![frmSearchMenu].[qLoadDate2]) AND ((tblLoad.AutoclaveID) Like [Forms]![frmSearchMenu].[qLoadAuto] & "*"));

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    But this isn't working as expected.....what am I missing.

    What happens when you run your query? Error message? Empty results? Unusual results?

    Alan

  3. #3
    Kevo is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2011
    Location
    Kodiak, Alaska
    Posts
    86
    Quote Originally Posted by alansidman View Post
    [/COLOR]
    What happens when you run your query? Error message? Empty results? Unusual results?

    Alan
    If I put in a date range it comes back as expected....but it simply ignores the second query field.

  4. #4
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Instead of Like in the second half of the Where clause try equals and delete the asterisk. What happens when you try that?

  5. #5
    Kevo is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2011
    Location
    Kodiak, Alaska
    Posts
    86
    OK, I think the problem is something to do with putting the criteria in the "and"/ "or" spot............

    I put the second criteria next to the first ("and" spot) and it ignores it.....put the second criteria in the "or" spot and it does either or but not both?????


    I want it to query between the 2 dates IF someone enters dates.....OR go to the next criteria and look for the Autoclave number and search records with that autoclave......But if someone puts in a date range AND an autoclave number it should return all records between those dates with that autoclave number....

    What am I missing?

  6. #6
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Is the autoclave number being entered manually or are you using a combo box that has a listing of the autoclave numbers?

  7. #7
    Kevo is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2011
    Location
    Kodiak, Alaska
    Posts
    86
    Quote Originally Posted by alansidman View Post
    Is the autoclave number being entered manually or are you using a combo box that has a listing of the autoclave numbers?
    Autoclave is a value already in a record.

  8. #8
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Even if autoClave number is in the record, someone has to enter something to find a record with a specific autoClave number.

    You should be working with a Form. A form that gathers parameters, and that will execute the appropriate query based on the selections made on the Form.

    see Martin Green's tutorials at http://www.fontstuff.com/access/acctut17.htm

  9. #9
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    What I was referring to was the form where you are entering the parameters. Is the text box (qloadauto) input manually, ie. typed in? or is it selected using a combo box?

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

Similar Threads

  1. Replies: 12
    Last Post: 05-07-2012, 12:41 PM
  2. Replies: 11
    Last Post: 04-30-2012, 07:22 PM
  3. Replies: 2
    Last Post: 08-04-2011, 08:07 AM
  4. Replies: 10
    Last Post: 07-12-2011, 11:09 PM
  5. Query including Null relationship?
    By David Criniti in forum Database Design
    Replies: 0
    Last Post: 08-14-2009, 09:10 PM

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