Help to modify a macro where condition in Access 2010

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mlgmlg
    New Member
    • Aug 2008
    • 6

    Help to modify a macro where condition in Access 2010

    Hello,

    I desperately need help to modify a where condition that was created when I added a button to open a form and find specific data by to display.

    The form currently opens and displays a form filtered by the task num (where condition below).

    Code:
    ="[task Num]=" & "'" & [task Num] & "'"
    This works great. When I click on the button, a form (Contractors) pop-ups and displays all records filtered by task num. Now, I would like to perform another filter on the field “contracto r”. So, the form will open, filter on task num AND contractor. How can I modify the above where condition to add the contractor field?

    Both my task num and contractor fields are text data types. I am using Microsoft Access 2010.

    My Contractor form is using a query for the record source.

    I appreciate your help and thank you in advance for responding. :-)
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Append an AND operator to the criteria string along with your new criteria.

    Comment

    • mlgmlg
      New Member
      • Aug 2008
      • 6

      #3
      Hi Rabbit, thank you so much for your response.

      I tried appending the "AND", but it is not working. Not sure if I am appending it correctly.

      Code:
      ="[Task Num]=" & [Task Num] & " AND Contractor = '" & Contractor & "'"
      :-(
      Last edited by zmbd; Nov 4 '13, 01:29 AM. Reason: [z{added the code tags}]

      Comment

      • mlgmlg
        New Member
        • Aug 2008
        • 6

        #4
        Hi Rabbit,

        This is the form I am trying to display.

        When a user clicks on a button, it will display the Rev Form by Task Num. We are trying to see what the next rev num to use for a particular contractor. The macro code works fine to display the associate task numbers, but I would like to do one more filter and that is to filter by contractor. So, the end results should display like Sample 2.
        Code:
        Sample 1:
        Rev Num	Task Num	  Contractor
        Rev-2	PJ55145	  Jamsinc
        Rev-1	PJ55145	  MLRNet
        Rev-0	PJ55145	  ToolsLink
        Rev-3	PJ55145	  ToolsLink
        Rev-4	PJ55145	  ToolsLink
        Code:
        Sample 2:
        Rev Num	Task Num	  Contractor
        Rev-0	PJ55145	  ToolsLink
        Rev-3	PJ55145	  ToolsLink
        Rev-4	PJ55145	  ToolsLink
        Last edited by zmbd; Nov 4 '13, 01:30 AM. Reason: [z{added code tags around the formatted text}]

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #5
          Task Num looks like a string to me and not a number. You need to surround string values in single quotes like you were doing originally. But you dropped it in your new code for some reason.

          Comment

          • mlgmlg
            New Member
            • Aug 2008
            • 6

            #6
            Yes, this is the actual macro statment:
            Code:
            ="[task Num]=" & "'" & [task Num] & "'"
            I was try to modify the original macro to add the statement to filter the contractor data as well, but I am having no luck with adding the AND to the end. Ugh! :-(
            Last edited by zmbd; Nov 6 '13, 07:52 PM. Reason: [Z{Please use the [CODE/] button to format posted code/html/sql/formated text - Please read the FAQ}]

            Comment

            • Rabbit
              Recognized Expert MVP
              • Jan 2007
              • 12517

              #7
              You just need to take your code from post #3 and put your quotes back in.

              Comment

              Working...