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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding a record based on a comboBox error msg

Status
Not open for further replies.

JimRich

Programmer
Oct 23, 2000
57
US
The code I am trying to used worked in an Access 97 application. However I am getting an error in 2000. Here is the code:

Sub cboFindLname_AfterUpdate()
Dim rst As DAO.Recordset
Dim strSearchName As String

Set rst = Me.Recordset
strSearchName = cmdFindLname.Column(1)
rst.FindFirst "lname = " & strSearchName
If rst.NoMatch Then
MsgBox "Record not found"
End If
rst.Close
End Sub

cmdFindLName.column(1) returns the correct value, in this case the last name of a client which happens to be "Hosier"

I get this error message with the pointer at 'rst.FindFirst "lname = " & strSearchName:
The Microsoft Jet Database engin does not recognize "Hosier" as a valid field name or expression.

Oh! the search engin in Tek-Tips is being worked on so I could not search to see if this question had been answered before.

Thanks.

JimRich
 
Try the following modification:

rst.FindFirst "lname = '" & strSearchName & "'"

This is the standard way of delimiting string variables within code.

John
 
That changed something. Now I get the message:

error 91 Object variable or with block not set.

Your help is appreciated. I am very frustrated just now.

Thanks.


JimRich
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top