Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2000 - Print report from a listbox?

Status
Not open for further replies.

BennyWong

Technical User
May 19, 2002
86
0
0
US
Hello All,
I had a form that contained 24 comboboxes in which the user selects their criteria and is saved into a table.
From that table I created a listbox and referenced the row source which is the query criteria. My question is how do
I print a report when the user selects the item in the listbox? Thanks for your help in advance.
 
Create a macro that runs whenever the After Update property of your list box is fired. The macro should consist of an OpenReport action that has the View value Print (to print the report immediately). Impose conditions on the OpenReport action to open different types of report depending on the value of the list box.

Hope this helps.
 
Hello JamieNC,
Thanks for responding to my post. I understand some of your solution. I understand the creation of the macro and insert it in the After Update property of the listbox. However, I don't understand how to "Impose conditions on the OpenReport action to open different types of report depending on the value of the listbox". What I have currently in the table is bunch of selected fields such as lastname, title, etc. selected from the user. How do I use this "selected fields" as the criteria for the query to generate the report. I think what I don't see is the conversion of what is in the table to the query then the report. How do I do it in the macro or do I need to code it?
Thanks for you patience and time.

Benny
 
Hi Benny,

Sorry for not replying to the thread for so long, I've only just checked it since writing my original response.

I'm not sure that I entirely understand the description of your problem, but I'll have a crack at it anyway.

As I interpret your thread, you want to create a listbox that displays all of the different field names of the table holding the data. Selecting one of these field names should then print a specific report.

In order to solve this problem, I would suggest the following:

Create an unbound ListBox that has all of the field names of the table as its List Items ('lastname', 'title', etc). Then give the ListBox a memorable name, eg 'tableFields'.

Next, write the macro. In the Condition column write the following expression:
Forms![FormName]![tableFields] = 'lastname'.
Then put your OpenReport action to open the corresponding report in the Action column, . This means that whenever the value selected in your ListBox is 'tablefields', the named report will be printed. Repeat this process for all of the other field names, changing the field name in the Condition column and the report to be printed in the Action column accordingly.

I hope this is the solution you are looking for. If I have not understood your problem properly, or my solution is unclear, please post back and I will try to help again.

Best of luck,

Jamie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top