SearchRecord by combo box

mkkashif

Registered User.
Local time
Today, 14:38
Joined
Sep 1, 2004
Messages
88
Hello Dear.
i have form with search combo box i am using this code it's working properly for Autonumber field but it is giving error for Text Field where is the problem
message """Data Type Mismatch""
can any body help me
Private Sub Search_AfterUpdate()
On Error GoTo ErrorHandler

Dim strSearch As String

strSearch = "[id] = " & Me![search]

'Find the record that matches the control
Me.Requery
Me.RecordsetClone.FindFirst strSearch
Me.Bookmark = Me.RecordsetClone.Bookmark

ErrorHandlerExit:
Exit Sub

ErrorHandler:
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description

Resume ErrorHandlerExit

End Sub
 
If [Id] is a number and Me![Search] is text then it won't work.

Col
 
Id also text

id is also text but there is error of mismatch datafield
 
If they're both text, then perhaps you need to enclose the Me![search] value in quotes:

strSearch = "[id] = '" & Me![search] & "'"
 

Users who are viewing this thread

Back
Top Bottom