Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FindFirst

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
I'm using the following code to find a record on my form based on what the user selects from the drop down box.

' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[Idkey]= '" & Me![cboSearch] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark

When a type a last name like "Smith" it works fine, but when a type a name like "O'conner" i get a run-time error 3077 - Syntax error missing operator in expresssion. It's obvoiusly the hyphen in the name that's causing the problem. What type of change does my code need? I've played around and just can't get it to work.

Thanks

MD

 
Change the FindFirst from

.FindFirst "[Idkey]= '" & Me![cboSearch] & "'"

to

.FindFirst "[Idkey]= " & Chr(34) & Me![cboSearch] & Chr(34)

The Chr(34) is ASCI for " John Ruff - The Eternal Optimist :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top