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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to have a Listbox be the Record Sorce for a Report 1

Status
Not open for further replies.

Accel45

Technical User
Jul 7, 2004
83
US
I have a form with a listbox. The form has command buttons on it to sort the items in the list box by name, date....
I want to be able to print a report that reflects how the listbox has been sorted.
How do I tie the listbox to the report.
For example, if I sort the listbox by name I want the report to be sorted by name, if I sort the list box by date I want the report to be sorted by date.

Help please
Accel45
 
Dear Accel45:

It is not too clear from you message how you are changing the record source of the list box. One idea might be to hold module level variables that reference the type of sorting you have on your list box. You could create the record source for the list source using these variables. When you run the report, you may ne able to launce the report using the same module level variables at the top of the form's code. Let me know if this does not work or if you already tried this.

Vel
 
VelNPS

This is the code I am using behide the command buttons for sorting:

Private Sub SortbyVolName_Click()
Dim strSQL As String

strSQL = "SELECT DISTINCTROW PersonID, VolName, PHomeP, DoorToDoor, SendPost, UseName "
strSQL = strSQL & "FROM qryVolNameList "
strSQL = strSQL & "ORDER BY VolName"

Me.List0.RowSource = strSQL
Me.List0.Requery
End Sub

Accel45
 
Like VelNPS said, with a Module level variable, you can manipulate it for either purpose, at the same time.

strSQL = "SELECT DISTINCTROW PersonID, VolName, PHomeP, DoorToDoor, SendPost, UseName "
strSQL = strSQL & "FROM qryVolNameList "
strOrder = "ORDER BY VolName"

Me.List0.RowSource = strSQL & strOrder

DoCmd.OpenReport "ReportName"
Reports!ReportName.OrderBy = strOrder
Reports!ReportName.OrderByOn = True

To be declared in a standard module, in the general declarations section.

Public strOrder As String


Hope this helps, good luck!


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top