Quick & Dirty method: (1) Edit the source query of the report and put in criteria for the Quarter & Year like [Enter Quarter] and [Enter Year] Now, when you run the query, it will prompt you for input.
(2) Open the form in design view and add a button to the form. (just cancel the wizard) Double click the button to open the properties of the button, go into the "Events" tab and select the "on click" event. Then use the drop down to select [event procedure]. Next click on the ellipse ... To open the MS VB editor and enter the following VBA code into the button's on_click sub: DoCmd.OpenReport "MyReportName", AcPreview In the button's properties, on the "Format' tab, you may then also want to edit the Caption to something like "&Report". (The Ampersand tells it to put an underscore below the next character and make it available to users via ALT-R or whatever letter you used) example: Re&ports Looks like this email forum forces email to text rather than HTML or I would include screenshots. Glad to help! -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of dawnmahc Sent: Friday, April 17, 2009 10:30 AM To: [email protected] Subject: [ms_access] Re: Button that will open a report based on quarter and year Hello, I first want to say, "Thank you so much for replying." I'd like to use your first suggestion with the query. Are you suggesting that I first create a button using the button wizard to pull up the results by quarter and year? If so, I've done this, but I'm not sure how or where to put in the click event [VBA code] that says: DoCmd.OpenREport "MyReportName", AcPreview I've added my database to the site if you would like to take a look. Thank you for any help you may have to offer. Dawn --- In [email protected] <mailto:ms_access%40yahoogroups.com> , "Peter Groman (peter.groman)" <peter.gro...@...> wrote: > > > (1) A quick and dirty way to do it would be to edit the source query > of the report and put in criteria for the Quarter & Year like [Enter > Quarter] and [Enter Year]. Then just create a button that has an on > click event [VBA code] that says: > > DoCmd.OpenREport "MyReportName", AcPreview > > (2) A more elegant solution would be to build a form that the user can > enter the values into text boxes or drop down boxes and the report > data source query can use them in the criteria for those fields like this: > > Forms!MyFormName.Quarter > Forms!MyFormName.Year > > (3) Yet another way would be to build the form and have it populate a > table. Then in the report data source query you can link to that table > and filter the data. Though you may have to use VBA to clear the table > before each use, as it would have data in it from the last run. > (Another way to get around that would be to use the last (most recent) > row via the MAX function, etc.) > > (4) If you will only ever be running the report for the current > quarter and year, then you can just hard code some formulas into the > report data source. > > > PS - Anyone know of any job openings? ;) > > - > Peter Groman > peter.gro...@... > > > > -----Original Message----- > From: [email protected] <mailto:ms_access%40yahoogroups.com> > [mailto:[email protected] <mailto:ms_access%40yahoogroups.com> > ] On Behalf Of dawnmahc > Sent: Thursday, April 16, 2009 8:18 AM > To: [email protected] <mailto:ms_access%40yahoogroups.com> > Subject: [ms_access] Button that will open a report based on quarter > and year > > > > Hello, > > I'm new to Access. I need to create a button for the end user that > will prompt for the quarter and year, then it will pull up the report > with that quarter and year. I have a table with qtr as the quarter and > year as year. I've created a Form that has a button called report. Can > you please help me? > > Thank you in advance. > > Dawn >
