Microsoft Access - Parameter Query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chicane
    New Member
    • Dec 2009
    • 8

    Microsoft Access - Parameter Query

    I am currently writing a query in Access. I need to set up a parameter query for three fields which are called Status (text field), Authorised (date field) and Legal notices (date field).

    I need to set it up so that the user can enter info into each of the fields and run the query from that but I also need to set it up so that if nothing is entered into the parameter boxes that it needs to return all results.

    I have set up the first parameter query for the status field which I have entered the text below into the criteria box. This appears to work ok.

    Like "*" & [status] & "*"

    When I try to use something similar on the other two fields to set up the parameter query the query doesn't return any results.
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    Did you try to change the datatype of the date fields into a string ?
    Just try the Format() function.

    Nic;o)

    Comment

    • kstevens
      New Member
      • Mar 2009
      • 74

      #3
      make your query criteria look like this
      Code:
      like "*" & IIF(Forms!MyFormName.DateFieldName is null,"",Forms!MyFormName.DateFieldName ) & "*"

      Comment

      • chicane
        New Member
        • Dec 2009
        • 8

        #4
        Access

        thanks for the replies. I will have another shot at it using your suggestions.

        Thank you

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          Try:
          Code:
          SELECT tblTest.Status, tblTest.Autorised, tblTest.[Legal Notices] _
          FROM tblTest _
          WHERE (tblTest.Status Like "*" & [Enter Status] & "*") OR _
          ( tblTest.Autorised Like "*" & [Enter Authorized Date] & "*") OR _
          (tblTest.[Legal Notices] Like "*" & [Enter Legal Notice Date] & "*");

          Comment

          Working...