FindFirst problem

Bruce75

Psychologist
Local time
Today, 17:27
Joined
Sep 29, 2004
Messages
46
I have the following code to go to a record from a list box.

Option Compare Database

Private Sub List15_DblClick(Cancel As Integer)
'Requires reference to DOA 3.6

Dim db As DAO.Database
Dim rst As DAO.Recordset

DoCmd.OpenForm "mainform"

Set rst = Forms!mainform.Recordset.Clone

rst.FindFirst "[ID] = " & Me.List15
Forms!mainform.Bookmark = rst.Bookmark

'DoCmd.Close acForm, Me.Name

End Sub


Private Sub Text13_Change()

Dim vSearchString As String

vSearchString = Me.Text13.Text
Me.Search2.Value = vSearchString
Me.List15.Requery

End Sub


It keeps saying that there is a syntax error (missing operator). I have no idea why. The mainform opens, but does not bring up the chosen record. Please help.
 
if ID is a string should probably be:

Code:
rst.FindFirst "[ID] = '" & Me.List15 &"'"

HTH

filo65
 
thanks for your prompt reply. unfortunately that does not work - comes up with an error saying that it is not a string.

ID is the primary key (autonumber)

I am not very good a computers. Please help.
 
Bruce

First step is to try and identify the line of code causing the error. Hit the debug button on the error msgbox which will take you to the relavent line of code. Have you tried setting a breakpoint and then stepping through your code you can then check in the locals window the actual values for the varrious variables and properties. It is not good practice to use autonumber to be anything other than a unique reference number ( lots of comments from Pat Hartman on this if you do a search ) and as you seem to be searching using a field which matches an autonumber field this may lie at the root of your problem
 

Users who are viewing this thread

Back
Top Bottom