Open form with 2 where clauses

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • elaspina
    New Member
    • Oct 2009
    • 5

    Open form with 2 where clauses

    I am trying to open a form based on 2 where clauses in a Human Resources database. I have a main form that has the employee name and type of benefit they are enrolled in. I want to then open a subform for the employee that then provides further detail on that particular benefit (i.e. I want to filter the form based on employee id and benefit type). When I only push one of the where clauses through the code it works fine, but when i try to combine them I get a Run-time error 13 Type Mismatch. Code is below. What am I missing?

    DoCmd.OpenForm "frm_Benefits_D ependants", acNormal, , "[EmployeeID]=" & [EmployeeID] And "[BenefitType]=" & "'" & [CMB_BenefitType] & "'"

    Thank you in advance for any help you can provide!!
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    The AND has to inside the parameter string, not out of it.

    Comment

    • elaspina
      New Member
      • Oct 2009
      • 5

      #3
      Can you elaborate on this? I'm a beginner when it comes to VBA. What is the parameter string?

      thanks a bunch!

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        It needs to be this
        Code:
        "[EmployeeID]=" & [EmployeeID] & " And [BenefitType]=" & "'" & [CMB_BenefitType] & "'"

        Comment

        • elaspina
          New Member
          • Oct 2009
          • 5

          #5
          This worked perfectly. Thanks a million!

          Comment

          Working...