Filtering a Report with a combo box (1 Viewer)

King Kreglo

Registered User.
Local time
Yesterday, 21:48
Joined
Aug 31, 2013
Messages
32
Firstly, sorry for all the questions today, the help is appreciated though :)

I have a form that filter records off of combo, I want the user to run reports based off of the filter selected in the combo box.

Here's the code I've been toying around with:

Code:
Private Sub ReQuote_Click()

Dim strCustomer As String
Dim Filter As String
    If IsNull(Me![cboFilter]) Then Exit Sub
        
        strCustomer = Nz(Me.cboFilter, "*")
        Filter = "strCustomer = "" & strCustomer""      "
        'Filter ="strCustomer = "" & Me.cboFilter""
    DoCmd.OpenReport "tblOrder Details", acViewReport, Filter
        
End Sub

I ripped it off of another thread on here but my needs are slightly different so I couldn't quite get it to do what I wanted, any ideas?
 

King Kreglo

Registered User.
Local time
Yesterday, 21:48
Joined
Aug 31, 2013
Messages
32
But note I'm pretty sure you have it in the wrong position.

Not sure what you mean by wrong position! I'm still an Access Amateur....

I plugged in your code though like so:
Code:
DoCmd.OpenReport "tblOrder Details", , , "Customer = " & Me.cboFilter & "'"

and it came up with this error:
Run-timer error'3075':
Syntax error in string in query expression 'Customer = John Doe".

Seems like it's close, just not sure where to go next!
 

King Kreglo

Registered User.
Local time
Yesterday, 21:48
Joined
Aug 31, 2013
Messages
32
Just to be clear here:

I was hoping to the report by customer!
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 21:48
Joined
Aug 30, 2003
Messages
36,126
You missed the single quote before the value. Try

DoCmd.OpenReport "tblOrder Details", acViewPreview, , "Customer = '" & Me.cboFilter & "'"

By position, I meant you were sitting instead of standing when you typed it. :p

Kidding, I meant in the wrong argument, ie the number of commas that came before it.
 

King Kreglo

Registered User.
Local time
Yesterday, 21:48
Joined
Aug 31, 2013
Messages
32
Hah! That made me 'lol'

That worked great though!!! Thanks so much!
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 21:48
Joined
Aug 30, 2003
Messages
36,126
Happy to help!
 

Users who are viewing this thread

Top Bottom