Results 1 to 7 of 7
  1. #1
    jlgray0127 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    185

    Open form using multiple criteria - VBA

    Good afternoon!


    Can someone please help? I'm getting the Syntax error and can not figure out what I'm missing!
    It's probably been 3 years since I've done anything major in MS Access, so any help is greatly appreciated!

    Private Sub Product_DblClick(Cancel As Integer)
    DoCmd.OpenForm "12 Week Supply Status_Pastdue", , , "[Product] = '" & Me.Product & " AND [LPA] = '" & Me.LPA & "'"
    End Sub


  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    missed a single quote before the AND. I exaggerated it below:

    "[Product] = ' " & Me.Product & " ' AND [LPA] = ' " & Me.LPA & " ' "



  3. #3
    jlgray0127 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    185
    Awesome! I did miss that! Thank you!
    It cleared my error out and opened the form, but it's not returning the results now.... interesting... it opens with no records to display. There are records. I can open the form and filter each field for the criteria. Perplexed, still. Any thoughts on why that is? They're both just text fields, so should work, I'd have thought.

  4. #4
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Try
    Code:
    Private Sub Product_DblClick(Cancel As Integer)
         DoCmd.OpenForm "12 Week Supply Status_Pastdue", , , "[Product] = '"  & Me.Product & "'"
    End Sub
    Are records returned?


    Next, try
    Code:
    Private Sub Product_DblClick(Cancel As Integer)
         DoCmd.OpenForm "12 Week Supply Status_Pastdue", , , "[LPA] = '" & Me.LPA & "'"
    End Sub
    Are records returned?


    Are you sure that you have records
    Code:
    WHERE "[Product] = '" & Me.Product & "' AND [LPA] = '" & Me.LPA & "'"
    Both conditions must be TRUE for records to be returned.



    Maybe you want records
    Code:
    WHERE "[Product] = '" & Me.Product & "' OR [LPA] = '" & Me.LPA & "'"

  5. #5
    jlgray0127 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    185
    Thank you for the response!
    I do get records to return in both of the first instances.
    The records are there, but it has to be "AND", rather than "OR". I need the individuals to be able to open the form and only display the records for the parts on the specific production line they are responsible for.
    I'm using the form to drill down, or filter down, to the information they are individually responsible for.
    I'm definitely perplexed why it is not working.

  6. #6
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Would you Post the dB??

  7. #7
    jlgray0127 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    185
    I did find a workaround. Thank you!

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

Similar Threads

  1. Double Criteria for Open Form
    By notrino in forum Programming
    Replies: 4
    Last Post: 10-24-2018, 03:15 AM
  2. Replies: 10
    Last Post: 04-10-2018, 03:19 PM
  3. Replies: 2
    Last Post: 10-08-2016, 10:06 PM
  4. Open 2nd Form with 2 criteria?
    By Robeen in forum Forms
    Replies: 1
    Last Post: 09-19-2011, 10:20 AM
  5. Replies: 1
    Last Post: 07-02-2010, 03:55 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