Combo filtering Report

AccessRobo

Registered User.
Local time
Yesterday, 20:01
Joined
Mar 27, 2012
Messages
12
Hope this is where I ask a question?
I want to filter a report using a combo box in a form. I have a PriceList table, that has the PriceListID, PriceListName etc. It is linked to the PriceListDetail table where the ProductID, MarkUp & Prices are.
I have three places I sell my goods at the moment, Auction, Website 1, Website 2. I have put a combo box in a form called frmPriceListReportCriteria. The combo box's name is cboListNameChoice.
I have a preview button on the form, it's name is cmdPreviewList.
My reports name is rptPriceListByName, this at the moment shows me all my Price Lists together. It has the PriceListName and below that the Products and the Prices, etc. I want to be able to see one PriceList at a time, ie. Auction or Website 1 or Website 2, if chosen.
I want to put the VBA code in the On Click (event procedure) of the Preview button (cmdPreviewList). Or will look at other suggestions. I am copying things from a tutorial book and trying to adapt them. The tutorial showed me how to filter using an option group. But my problem is that if the user makes more price lists, then those would not be included in the options, and I can't keep redoing the code. I therefore want to use a combo box.

Thank you for any suggestions.
 

Attachments

Thank you Paul
I will study your code later and see if it helps me.
Cheers, Craig
 
No problem Craig. Post back if you're still stuck. I'm still on an iPad so can't look at the sample, but I'll be at a pc later.
 
Thank you for saying you will look later.
Paul I could not get things to work, but came across another place where you helped someone. And by looking at both places I believe it is now right.
Here is my code for those who might be interested.
Please if you see anything in my code that needs attention, please let me know.
Private Sub cmdPreviewList_Click()
On Error GoTo ErrorHandler:
Dim strReportName As String
strReportName = "rptPriceListByName"

DoCmd.OpenReport strReportName, acPreview, , "PriceListName = '" & Me.cboListNameChoice.Column(1) & "'"

CleanUpAndExit:
Exit Sub

ErrorHandler:
Call MsgBox("An error was encountered" & vbCrLf & _
vbCrLf & _
"Description: " & Err.Description & vbCrLf & _
"Error Number: " & Err.Number, , "Error")
Resume CleanUpAndExit

End Sub

Thank you for you help Paul. I really appreciate it. Cheers for now, Craig
 
Glad you got it sorted out Craig.
 

Users who are viewing this thread

Back
Top Bottom