Combo Box not working

D

davethewelder

Hi, I am trying to get a combo box to work where I select the surname from a
drop down list and it displays the other fields of the record in the form.
The code I am using is in the AfterUpdate event and the author is Carl Rapson

Private Sub Combo24_AfterUpdate()
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
rs.FindFirst "[Surname]=" & Me.Combo24 & ""
If Not rs.EOF Then
Me.Bookmark = rs.Bookmark
End If
End Sub

The combo box row source is SELECT TBL_PATIENT.SURNAME FROM TBL_PATIENT
ORDER BY [SURNAME];

The error message I am getting is

Run-time error '3070'

the Microsoft Jet database engine does not recognise 'ALLEN' as a valid
field name or expression.

I am going round in circles so any help would be appreciated.

Davie
 
S

Stefan Hoffmann

hi Davie,
Hi, I am trying to get a combo box to work where I select the surname from a
drop down list and it displays the other fields of the record in the form.
The code I am using is in the AfterUpdate event and the author is Carl Rapson
You are searching for a string, thus you must enclose it into quotes:

rs.FindFirst "[Surname]='" & Replace(Combo24, "'", "''") & "'"


mfG
--> stefan <--
 

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