Printing a report based on query generated from listbox!

Sharky II

Registered User.
Local time
Today, 18:46
Joined
Aug 21, 2003
Messages
354
Hi there!

I have a listbox, (which grabs its data from a stored query) that can be sorted by the user using buttons on the form - eg i have a button which allows the user to sort listbox results by ascending price.

There is also a button which lets you print a report, which is generated containing the results of the original query.

However when the items are re-sorted by the user, according to (continuing with the example) ascending price, a new query is created on the fly in the onclick event for the button, using code such as:

Me.MyListBox.RowSource = "Select Field2, Field1 From SomeTable Order By Field2 Asc"
Me.MyListBox.Requery

The Report, however, doesn't know anything about this new resorted/reordered information, and so just prints in according to however it is stored in the original query?

Basic question is - i want to let the user print a report with the records viewed as they last sorted them in the listbox - how can i make and print a report which is generated using whatever query the listbox has? How can i change the record source to the latest query from the listbox?

I hope this is clear - i've been awake quite a long time now!

Thanks

Edd
 
Hey i was just thinking - instead of updating the listbox like so:

Sharky II said:
Me.MyListBox.RowSource = "Select Field2, Field1 From SomeTable Order By Field2 Asc"
Me.MyListBox.Requery

Is it possible to update the query itself from the VBcode, and then the report would work perfectly?

I think i need to use CreateQueryDef function or something?

:confused:
 
Last edited:
don't worry, i sorted it!
 

Users who are viewing this thread

Back
Top Bottom