Update form from combo box

poporacer

Registered User.
Local time
Today, 14:57
Joined
Aug 30, 2007
Messages
136
I have a form that has a combo box. I want to use the combo box selection to populate the form. The problem seems to be that the Field that the combo box is using is in the form of A-12345. One letter, a hyphen and 5 numbers. I have tried a few different methods that have worked in the past but it doesn't work.
Here are the details:
The form is bound to a query. The combobox is populated by a query that pulls the IDNum from the table that the form is based on. I have the on update event of the combo box:

Private Sub cmbID_AfterUpdate()
Me.FilterOn = True
Me.Filter = "IDNum=" & Me.cmbID
Me.Requery
End Sub

When this is run, I get an popup that says to enter the Parameter Value and has the first character listed.

The other method I used was:

Private Sub cmbID_AfterUpdate()

If IsNull(cmbID) Then Exit Sub
Me.RecordsetClone.FindFirst "[IDNum] = " & Me![cmbID]
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub

And when this runs I get an error that states "The Microsoft Jet Databse engine does not recognize 'A' as a valid field name or expression. Where 'A' is the first character in the IDNum. I am sure it probably has something to do with quotation marks...If that is the case is there somewhere that explains how to use them? I have seen some wierd ways of quotes to make things work. Whichever method is easier will work for me...
Thanks
 
If it's a text value, try:

..."IDNum='" & Me.cmbID & "'"
 
That was it....I have had a quote issue in the past.....How do you know when to use Single, double quotes, etc???

Thanks for the quick response!!!
 
Generally, single quotes around text values, # around date values, nothing around numeric values. Your original effort would have been fine for a numeric value.
 

Users who are viewing this thread

Back
Top Bottom