Error 2001 When using VBA for filtering Records

J

J. B.

Hi all,

I have been trying to use VBA to filter records on a form. I keep
recieving the run time error 2001 "You have canceled the last operation".
Here is the code that I am using:

Private Sub cboCompanyName_AfterUpdate()
If IsNull(Me.cboCompanyName) Then
Me.FilterOn = False
Else
Me.Filter = "Cust_ID = """ & Me.cboCompanyName & """"
Me.FilterOn = True
End If
End Sub

I recieve the same error is I was to use this syntax:
Me.Filter = "tblCustomer.Cust_ID = """ & Me.cboCompanyName & """"

The combo box is using a query that displays the Customers Name in the first
column and is bound by the second column which is the Cust_ID value. I
don't know if this has anything to do with the error.

Any help would be much apreciated.

Thanks in advance,

J. B.
 
V

Van T. Dinh

Is Cust_ID a Text Field or a Numeric Field?

If it is a Numeric Field, use:

Me.Filter = "[Cust_ID] = " & Me.cboCompanyName
 

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