Want to open report from selection in combo box

Mansoor Ahmad

Registered User.
Local time
Today, 23:00
Joined
Jan 20, 2003
Messages
140
Dear All

On a form I have a command button that on click opens a report, based on the selection made in a combo box on the same form.

I have used following code. It does open the report but does not show any data. Can somebody advice please.

Private Sub CmdVin_Click()
Dim stDocName As String
Dim vinno As String
vinno = "Forms![New form Sample]!Combo100"
stDocName = "R_VIN nos summary"

DoCmd.OpenReport stDocName, acPreview, , "[CUSTOMER] = '" & vinno & "'"

End Sub

Thanks
 
there's an example in this thread you can take a look at.

This example uses a macro to open the report but if you don't want to use a macro to do this, all you need to do is enter the criteria in your query to look for a value in your combo box. Base the report on your query and on click of the cmd button just use docmd.openreport "reportname", acviewpreview.

If you want to stick with your above code I am happy to look at it for you if you post up your db.
 
Thank you for your reply and the link.

Unfortunately I could not open it on my PC.

I do not want to use macro. Regarding using combo box reference in query cirteria, I was avaoiding to do it because I may be using the same query for other reports. But if that is the only option I can do that as well.
:) :)
 

Users who are viewing this thread

Back
Top Bottom