Full Version: Find records in a different form
UtterAccess Forums > Microsoft® Access > Access Forms
Oszie
Hi All
created a database with all my employees in, now my first form will ask for the employee number then I add a search button, which will take me to my second form with all the details of the that employee, but my code is not working, it takes me to my first record on my database please will anyone advise on were i went wrong? it gives me an error ( Data mismatch in criteria expression.)
Private Sub Command7_Click()
On Error GoTo Err_Command7_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Employee Detail"

stLinkCriteria = "[Employee Number]=" & "'" & Me![Text2] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command7_Click:
Exit Sub
Err_Command7_Click:
MsgBox Err.Description
Resume Exit_Command7_Click

End Sub
Larry Larsen
Hi
Could you give us an example of this employees number..!!!
thumbup.gif
MrSiezen
First you have one " & too many:
tLinkCriteria = "[Employee Number]= "'" & Me![Text2] & "'"
Assuming that Text2 contains a numeric value, it should be:
stLinkCriteria = "[Employee Number]="" & Me![Text2] & ""
And then you don't need encapsulate it anymore:
stLinkCriteria = "[Employee Number]=" & Me![Text2]
Oszie
thank you, its working now
egards
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.