Same query with filter

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Smiley

    #1

    Same query with filter

    I want to use one query but apply it to 4 different forms. So if Category
    field = 1 then only display items with Category =1 on form1, if Category =
    2, all items with category = 2 display on form 2. Is this possible ? If so
    how.

    Many thanks


  • Marshall Barton

    #2
    Re: Same query with filter

    Smiley wrote:
    >I want to use one query but apply it to 4 different forms. So if Category
    >field = 1 then only display items with Category =1 on form1, if Category =
    >2, all items with category = 2 display on form 2. Is this possible ? If so
    >how.

    One or two newsgroups would have been sufficient, no need to
    crosspost to so many groups.

    The best way to do that is to create a master form to open
    your form. The code behind a command button to open your
    form with a specific category could be something like:

    DoCmd.OpenForm "name of the form", , , "Category=1 "

    Alternatively, you could have a text or combo box on the
    master form where users can enter or select the category.
    Then the query can use a criteria of this type:
    =Forms![name of master form].[name of text box]

    --
    Marsh
    MVP [MS Access]

    Comment

    • Smiley

      #3
      Re: Same query with filter

      Thanks Marshall

      "Marshall Barton" <marshbarton@wo wway.comwrote in message
      news:75scr29773 c457qk10pv3jh0b tv1so6gnb@4ax.c om...
      Smiley wrote:
      >
      >>I want to use one query but apply it to 4 different forms. So if Category
      >>field = 1 then only display items with Category =1 on form1, if Category =
      >>2, all items with category = 2 display on form 2. Is this possible ? If so
      >>how.
      >
      >
      One or two newsgroups would have been sufficient, no need to
      crosspost to so many groups.
      >
      The best way to do that is to create a master form to open
      your form. The code behind a command button to open your
      form with a specific category could be something like:
      >
      DoCmd.OpenForm "name of the form", , , "Category=1 "
      >
      Alternatively, you could have a text or combo box on the
      master form where users can enter or select the category.
      Then the query can use a criteria of this type:
      =Forms![name of master form].[name of text box]
      >
      --
      Marsh
      MVP [MS Access]

      Comment

      • Lyle Fairfield

        #4
        Re: Same query with filter

        On Jan 23, 3:40 pm, Marshall Barton <marshbar...@wo wway.comwrote:
        The best way to do that is to create a master form to open
        your form. The code behind a command button to open your
        form with a specific category could be something like:
        >
        DoCmd.OpenForm "name of the form", , , "Category=1 "
        Why is that the best way?

        Comment

        • Marshall Barton

          #5
          Re: Same query with filter

          Lyle Fairfield wrote:
          >On Jan 23, 3:40 pm, Marshall Barton <marshbar...@wo wway.comwrote:
          >
          >The best way to do that is to create a master form to open
          >your form. The code behind a command button to open your
          >form with a specific category could be something like:
          >>
          >DoCmd.OpenFo rm "name of the form", , , "Category=1 "
          >
          >Why is that the best way?

          I was thinking that user interactions with the query
          selection process would be cumbersome if a form was not
          involved.

          --
          Marsh

          Comment

          Working...