List box problem

deejay_totoro

Registered User.
Local time
Today, 19:17
Joined
May 29, 2003
Messages
169
Hello,

I have an usual problem with a list box.

A listbox is placed on a form, which references a table with staff details. The list box is setup to select a record based on the choice the user makes.

So far, no problem. The user can select a name from the list and it will select the corresponding record.

Until the user selects any name using an apostraphe. For example, selecting the name O'NEILL or O'DONELL or O'CONLON etc... causes an error. The error and associated code are:

run-time error '3077':

syntax error (missing operator) in expression.

Private Sub List84_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[StaffName] = '" & Me![List84] & "'"
Me.Bookmark = rs.Bookmark
End Sub


So there appears to be a problem selecting a record based on the "O'". How can I resolve this.

Thank you very much!

dj_T
 
Two "", in strings, is the equivalent of one "

As you have noticed, apostrophes can cause problems with such names.

Replace it like this:

rs.FindFirst "[StaffName] = """ & Me![List84] & """"
 
Great!

Ah thats great!

Works fine now.

Thank you for your help.

dj_T
 

Users who are viewing this thread

Back
Top Bottom