Access 97: InputBox to pass arguments for generating reports

  • Thread starter Nimmi Srivastav
  • Start date
N

Nimmi Srivastav

I am a newbie when it comes to VBA and MS-Access. I have created a
report for my database using the Report Wizard. Currently the report
prints all the contents in my database in columnar format. I would
like to pass some arguments (through an input box) that will allow me
to print only selected rows from my database in the report. For
example, my database has a date field and if I provide beginning and
end dates in the InputBox, I would like only rows for which the date
field lies within the specified range to be printed. Can someone tell
me how to go about it?

BTW, Northwind Traders database, that comes with Access, provides this
kind of capability for the Employee Sales by Country Report.

Regards,
Nimmi
 
G

Guest

As far as I can see, the north wind report you mention is using a query for
the basis of the report.

Base your report on a query, in the criteria row of the date feild type the
following.

Between [Enter the first Date] And [Enter the Second Date]

Now, when the report is run, an inputbox will request the first date and a
second one the final date.

Your report will be limited to between those two dates.

If I have read your question correctly, thats what you want to do. If you
want to start the report from a form in the same way that they do in
northwind then simply make a form and use the wizard to make the button to
run your report. From the tools menu with your form in design mode, select
the make button command, drag outline shape on your form, the wizard will
start, select Report Operations\Preview or Print Report.

Hope this helps

Mike B
--
Advice to Posters.
Mark as answered when completed.

Check your post for replies or request for more information.

Have the COURTESY to send an ending note even if the answer didn''t work.
 
G

Guest

To add some to Mike's answer, you can accomplish this by basing your report
on a parameter query as he indicates. However, I prefer to use a form. You
can have your query look to the form for it's parameters. If you make a
mistake when entering data in a parameter query, which includes more than one
parameter, there is no way to go back and correct the first entry. Also, once
the query runs, if you want to re-run it with a change in only one parameter,
in a multi-parameter query, you will have to re-enter all of the parameters.
If you use a form, you can simply hide the form, and then re-open it and all
of your parameters will still be there.

It is also helpful to include a NoData event procedure in the report, and
trap for and discard Error 2501 in the code used to open the report. Here is
an example that you can download, which you may find helpful:

http://home.comcast.net/~tutorme2/samples/customdialogbox.zip


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top