FindFirst Multiple Criteria Syntax

Bombshell Disaster

Registered User.
Local time
Today, 09:08
Joined
Nov 21, 2007
Messages
32
Hi Guys
Can you look at my code and tell me where I may be blind! HospitalSiteID is a text field and PatientID is an autonumber field. When I break the criteria down it is fine but when I have multiple criteria using And then I get the datatype mismatch error. I am thinking it may have something to do with the And operator and the quotes?
Many thanks

Code:
Dim HospitalSiteID As String
Dim PatientID As Integer
Dim strCriteria As String
 
strCriteria = "[HospitalSiteID] = '" & HospitalSiteID & "'" And "[PatientID] = " & PatientID
 
rs.FindFirst strCriteria
...
 
Here:
Code:
strCriteria = "[HospitalSiteID] = '" & Me.HospitalSiteID & "' And [PatientID] = " & Me.PatientID
Notice that And is now inside the quotes.
 
Thank you vbaInet, just what it needed. Have learnt for next time, cheers.
 

Users who are viewing this thread

Back
Top Bottom