Filter Records based on two combo boxes

AgDawg

Registered User.
Local time
Today, 15:27
Joined
Oct 12, 2012
Messages
24
I am not sure what I am doing wrong. Just need to filter records to only show whats selected in the sales rep combo box and and the customer combo box. This should be pretty simple.

Here is what I have:

Code:
Private Sub Combo60_AfterUpdate()
Me.Filter = "[Customer]='" & Me.Combo60 & "'" And "[Sales Rep]='" & Me.Combo67 & "'"
Me.FilterOn = True

End Sub
 
ok went back and renamed the controls. The sales rep will always have a value as I am going to have it set and disabled before the end user gets the database. So here is what I have now:

Both combo boxes are in text form. It give me a runtime error '13' Type mismatch message.

Code:
Private Sub cboCustomer_AfterUpdate()
Me.Filter = "[Customer]='" & Me.cboCustomer & "'" And "[Sales Rep]='" & Me.cboSalesRep & "'"
Me.FilterOn = True
 
The lookups for each combo box is coming from a query. Both lookups have one column. I tested it with the search for record macro and it goes to the first instance of the record in the datasheet but what I want to do is only show those records where the sales rep and customer name match whats selected in the combo boxes.
 
Thanks for all your help. The first combo box cboSalesRep works perfect and filters the sheet and only shows records matching the sales rep that picked in the combo box.

I am still getting a type mismatch after I select the customer from the cboCustomer combo box. In the query and table the customer name is always text. There are numbers in the field along with the text but from the tables to the query its always in text type. Here is an example what the data looks like in the cboCustomer box: AgDawg_0001
 
See attachment for my database. I thought maybe I might catch something while I put in dummy data but its still giving me the same return.
 

Attachments

Very much appreciate you helping me out. Works like a charm now.
 

Users who are viewing this thread

Back
Top Bottom