My Assistant
![]() ![]() |
|
|
Apr 26 2010, 03:48 PM
Post
#1
|
|
|
New Member Posts: 5 |
Dear All,
Firstly apologies if this is in the wrong place (feel free to move) or has been asked already (maybe I'm searching wrong). I have a query in Access 2007 that I want to use to generate a report. Wanting the user to have the option to set stuff like date ranges etc I decided to go down the route to use a form to input the parameters. The help document I followed was: http://office.microsoft.com/en-us/access/HA100963141033.aspx So I now have a form that I can open - input the data etc. However when I run the query the parameters asked for (Between [Forms]![MyForm]![StartDate] And [Forms]![MyForm]![EndDate]) come up as popup boxes. If I have opened the form myself previously and set the data then it runs ok using that data (so is getting input from the form ok). The problem I have is that I want the form to automatically open whenever that query is run. The tutorial has me create various Macros to enable this but then in the last bit just says about the parameters. I could of course just add an action to the "Ok" button of the form to run the query then start by displaying the form and that will in turn run the query but I really want the query to open the form for input wherever it is run from - so that any reports using data from the query will run the query which will open the form. I'm sure it's just some really simple error I am making - I was half expecting to see a macro option or other for the query properties but can't see anything. I hope that is clear enough; but in summary: I want a query to open a form to get the parameters which are referenced in the query Thank you in advance for any help or advice you can provide. Kind regards, Dave. |
|
|
|
Apr 26 2010, 03:54 PM
Post
#2
|
|
|
UtterAccess VIP Posts: 20,228 From: Colorado |
Hi Dave,
> "he problem I have is that I want the form to automatically open whenever that query is run. " that is backwards ... open the form, put the parameters in and then make a button to open the report that is based on the query with the parameters. Alternatively, you can use the Where parameter of the OpenReport action and skip the parameters in the query |
|
|
|
Apr 26 2010, 04:04 PM
Post
#3
|
|
|
Utterly Eccentric and Moderator Posts: 3,696 From: Bristol / Ipswich / Spain |
Greetings and a warm welcome to UA.
Why do you need to open the Query before opening the report? You can open the Report directly from your Form if it (the Report) is based on the Query. Enable Wizards on your Form, drop a command button onto your Form and follow the wizard to create code or a macro to open the Report. HTH Please post again and we hope you have a great time at UA: Zocker |
|
|
|
Apr 26 2010, 04:32 PM
Post
#4
|
|
|
New Member Posts: 5 |
Hi Guys,
Thank you very much for your blindingly fast reponses! I can see how I could run the query (or the report) from the form itself and this may be the ultimate solution. However I was hoping to find a way of making the query open the form. I appreciate this may seem backwards but what I'm after is a query that "self supports" if you like for input parameters. In this way any time I use the query, from any number of reports or from anywhere/anything else it will ask for the data. This saves having a form for every report or time I want to use the query (though I suppose I could always have multiple buttons on the form for which report/next step is called). If I set simply parameters for the query these popup boxes are displayed whenever the query is run - I was hoping to mimic the same behaviour but using a form instead to allow complex controls. The MS tutorial I followed seemed that it would do this - there is a VBA module to open the form if it's not opened, Macros which it says are used by the query etc etc but just nowhere does it mention how to get the query to fire off these macros when it is run. Thanks again for your help - any further clarification you can offer is very much appreciated. Regards, Dave. |
|
|
|
Apr 26 2010, 04:34 PM
Post
#5
|
|
|
UtterAccess VIP Posts: 20,228 From: Colorado |
Hi Dave,
> "However I was hoping to find a way of making the query open the form. " this is not an option unless you do it with code ... like in a form. Cannot attach code to a query. If the form is not open, you will be prompted for the parameters. I find that making a ReportMenu form works great to collect criteria and launch everything -- reports and queries. |
|
|
|
Apr 26 2010, 04:39 PM
Post
#6
|
|
|
New Member Posts: 5 |
Hi,
Ok I will go down that route then. Thanks again for your help. Kind regards, Dave. |
|
|
|
Apr 26 2010, 04:57 PM
Post
#7
|
|
|
UtterAccess VIP Posts: 20,228 From: Colorado |
you're welcome, Dave (IMG:style_emoticons/default/wink.gif) happy to help
|
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 20th June 2013 - 05:05 AM |