Results 1 to 11 of 11
  1. #1
    funkygoorilla is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    93

    Query by Form to Report

    Hi,


    I created a dialog form where a user can enter parameters into a query. I tested this and it works just fine, but I would like to know how to get this process to instead of opening the query results in a datasheet view, how to get it to open in the intended report? Basically I would like it to be as easy as putting in the query parameters in the form, then click OK, and then the report opens. Is this possible?
    Thanks in advance, FunkyG.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Most of my reports are based on queries that get parameters from forms. Have you tried creating a report based on the query? Personally I have a button on the form open the report if the criteria have been properly entered, but some people open the form from the open event of the report.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    funkygoorilla is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    93
    Hi, I have succesfully created a report that uses a query to get information. My goal of that is to reduce the amount of information the user would have to enter in the parameters. hence why I chose to go form based. I think clicking an "Ok" button would be awesome, but how do I set it up to use the criteria selected in the form?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I thought the query already got parameters from the form? In the criteria row:

    Forms!FormName.ControlName
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    funkygoorilla is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    93
    My query does get the parameters from the form, but I want the end result to display my original report and not the query.
    Here is one of my parameters;
    [Forms]![frmQueryByForm]![txtSenID]
    It is basically a text box. Currently when I hit Ok on the form, it opens the query results, but I would like it to open the report. Sorry if I am not being to clear on this.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Maybe I'm not being clear. Create a report that uses that query as it's record source. Then open the report rather than the query (the macro or VBA code would be OpenReport instead of OpenQuery). The report runs the query itself in the background.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    funkygoorilla is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    93
    If I choose to open the report, can I do so while using the criteria from the form?

  8. #8
    funkygoorilla is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    93
    Ok, so after reading your last post a couple hundred times, I figured it out. But, the report auto prints right away. Any idea how I can get it to just show?

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    One of the arguments of OpenReport determines whether it prints or previews. The default is to print, so leaving out that argument will cause it to print. Check help on OpenReport to see the correct syntax.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    funkygoorilla is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    93
    OK I got it. Its acViewPreview. Thanks for the guidance!

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 07-15-2011, 10:59 PM
  2. Replies: 1
    Last Post: 05-04-2011, 03:51 PM
  3. Report From Form Based Query
    By cartotech81 in forum Reports
    Replies: 1
    Last Post: 02-16-2011, 06:33 PM
  4. Help with Form & Report that calls a Query
    By bobfin in forum Reports
    Replies: 7
    Last Post: 08-14-2010, 12:05 PM
  5. Report with Parameter Query/Form
    By maggioant in forum Reports
    Replies: 0
    Last Post: 10-09-2009, 09:48 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