Error while Changing Form.Filter in VBA

M

Mike

Hi. I have a combobox OnChange event which should update a form's datasource
base on the combobox's value in Colum1. Code is below. But when this code
executes I get the error "Run-time error '2001': You canceled the previous
operation."

Private Sub FilteredContacts_Change()
Me.Form.Filter = "[Contact_ID] = '" & FilteredContacts.Column(1) & "'"
Me.Form.FilterOn = True
End Sub

What am I doing wrong or how do I fix this?

Thanks!
 
D

Douglas J. Steele

That very misleading error message often occurs when you've misspelled the
name of a field in your statement.

Are you sure that the name of the field in the form's underlying recordset
is Contact_ID and not, say, ContactID or Contact ID?

Are you sure that it's a text field, and not a numeric field?
 

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