Database Filter Criteria (1 Viewer)

J

jason_canada

Guest
Hey everyone! I need to filter a database using two criteria values.

The values are: text box value from txtClientID and the string 'P'. The values in the database are the ClientID and the DomainType, either a P or an A. In this search it is for P. Can someone help me write a criteria string? This is what I have come up with, but it doesn't work!

strcriteria = ("[DomainType] = 'P' And [ClientID] = " & txtClientID)

rstDomain.FindFirst strcriteria

Any help will be appreciated.

Lieu
 

dennyryan

Registered User.
Local time
Today, 04:01
Joined
Dec 21, 1999
Messages
45
I assume that ClientID is a text field, in that case your string should read as follows:

"[DomainType] = 'P' And [ClientID] = '" & txtClientID & "'"

You need to imbed single quotes around txtClientID (if ClientID is a text field) and you shouldn't have parentheseis around the string (at least per the example in Help).


Denny
 
J

jason_canada

Guest
Thanks for the response Denny but the code you gave me didn't work. I am getting an error "Data Type mismatch in criteria expression". Any ideas??
 

dennyryan

Registered User.
Local time
Today, 04:01
Joined
Dec 21, 1999
Messages
45
Check the data type on the ClientId in your table. Perhaps it's a number, in which case you wouldn't want the single quotes around the txtIDField like I recommended.

Maybe your problem was just having the parentheses included in your original statement. Eveything else in your original code looks ok if ClientID is a numeric field type.

Denny
 

Users who are viewing this thread

Top Bottom