Printing From Form, Items In A list

Cavern

Registered User.
Local time
Today, 19:31
Joined
Jul 12, 2002
Messages
31
Just another quick question,
Ive got a form where I select an option from a combo-box, and then a list box is populated with a list of companies based on what I pick for the combo-box (ie. 'All Companies Exporting', 'All Companies Registered', Etc..). The list-box has 3 columns, the [Record ID] of the company, the [Company Name] and a third column that changes depending on what the user has selected.

I was wondering if there was some way to get a report to print only for those companies that are appearing on the list. For instance, if the user wants to print all the companies taht are exporting:
They Select the 'All Companies Exporting' from the combo-Box, then they press a control-button for 'Print These Companies', and the Report prints out for these companies.

I already have the form I would like to use to print the information built.

Thanks for your time,
-Cavern
 
DoCmd.OpenReport "YourReportName", acPreview, , "YourField = " & Me.YourCombo

If the value in the combo is text, then the value from the combo needs to be surrounded with quotes:

DoCmd.OpenReport "YourReportName", acPreview, , "YourField = " & Chr(34) & Me.YourCombo & Chr(34)
 
Thanks for the reply... But I think I mis-phrased the question. I understand how to load the form based on a single field, but the problem I'm having is that sometimes the fields that are used to populate the listbox change.. For instance, sometimes the list-box might contain all the companies that are exporting (based on the [Exports] field), and sometimes it might be a list of all the companies that are located in Ontario (based on the [Province] field).... I understand that I could write a bunch of IF... THEN statements to check what the list is being loaded by, and send the correct field information clause, but this doesn't seem like a very elegant solution to me, however its the only one I can come up with right now :).

What I'm really looking for is a way to have the report load with the exact same companies that are in the list-box, without saying they must have a field 'whatever' with a value 'whatever'....
I'm probably going to have to stick it out and make the IF... THEN solution just because I'm a little stuck for time, but if there's a better way I'd love to set that up instead!
 

Users who are viewing this thread

Back
Top Bottom