Results 1 to 6 of 6

Modify to use 1 query

  1. #1
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    679

    Modify to use 1 query

    Short version:
    I want to use 1 query with a change in criteria difference. This way I can drop 1 report.

    I have been clicking CB1 to open qry1 with output on rpt1 and
    CB2 to open qry2 with output on rpt2

    QRY1 and QR2 have the same fields, but with differing criteria. Report1 and Report2 are the same but look at different query for information.

    Example
    Query1 - Criteria - <> X in Column 1


    Query2 - Criteria - <> Y in Column 1 and = X in Column 2

    Command Button1 opens Query1 and spits out Report1
    Command Button2
    opens Query2 and spits out Report2

    I would like to click CB1 to open Query1 with qry criteria and spit out info in Report1 and
    click CB2 to open Query1 with QR2 criteria and spit out info in Report1

    Basically making 1 query with changing criteria pushing information to 1 report.

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    18,948
    I would probably take the criteria out of the query and just use appropriate versions of this:

    http://www.baldyweb.com/wherecondition.htm
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

  3. #3
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    679
    Paul,
    I'm not using a second form. if I can get 1 query to change criteria depending on what button is selected, then I can use 1 form.

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    18,948
    I mean to use that method to open a single report with different criteria. Using your examples:

    DoCmd.OpenReport "ReportName",,, "Field <> 'X'"
    DoCmd.OpenReport "ReportName",,, "Field <> 'Y' AND OtherField = 'X'"
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

  5. #5
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    679
    Thanks Paul,
    I'll give it a shot.

    "Field <> 'Y' AND OtherField = 'X'" ..... meaning I need to put in all the fields, or only the ones where the criteria changes?

    Grazi


  6. #6
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    18,948
    You put in whatever criteria you want applied in each instance.
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 3
    Last Post: 05-24-2017, 12:26 PM
  2. modify a filed in a query
    By ArvinFx in forum Queries
    Replies: 3
    Last Post: 02-15-2017, 04:57 AM
  3. modify parameter query
    By NightWalker in forum Queries
    Replies: 5
    Last Post: 08-18-2016, 05:11 PM
  4. Replies: 5
    Last Post: 09-17-2014, 06:28 PM
  5. Modify a query
    By saray in forum Queries
    Replies: 2
    Last Post: 06-08-2013, 01:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Tech Forums: Microsoft Office Forums