Filter a report based on a Combo Box

S

Shiree

This is the last bit I need to finish a DB - its driving me mad.

I have a report - that I want to filter based on the record of the form.
It works perfectly fine for the unique ID Field [Asset Number]

But for the field that uses a combo box, I keep getting Error, please please
help!

Report is called R_Asset.
Field to match on is called [Sub Precinct]

If I swap the field name to [Asset number] this works perfectly
===================

The code is:

Private Sub RunReport2_Click()

Dim strDocName As String
Dim strWhere As String
strDocName = "R_Asset"
strWhere = "[sub precinct]=" & Me.[Sub precinct]
DoCmd.OpenReport strDocName, acPreview, , strWhere

End Sub
 
K

Ken Snell MVP

I'm guessing that your Me.[Sub precinct] field is a text value, so use this
(I'm delimiting the value with ' characters):

Private Sub RunReport2_Click()

Dim strDocName As String
Dim strWhere As String
strDocName = "R_Asset"
strWhere = "[sub precinct]='" & Me.[Sub precinct] & "'"
DoCmd.OpenReport strDocName, acPreview, , strWhere

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top