View Full Version : Search for record using 2 fields as criteria


limhodav
09-27-2005, 10:31 PM
Hi all,

May I know what is the easiest way to search for records using 2 fields wich are not primary keys? and then return a boolean value whether it is found or not...

These 2 fields are of integer type.

Recordset.Find can only find record with one field and not two.

Is there any codes available for this?

Thaks a million in advance

FoFa
09-28-2005, 11:01 AM
You could use DCOUNT or a FUNCTION.
DCOUNT("PrimaryKeyCol","TableName","Field1 = " & SomeNumber & " AND Field2 = '" & SomeString & "'"
As an example

limhodav
09-28-2005, 08:06 PM
Thanks .... I found a easy way but til now i received syntax or data type error ....

Here's the code .... maybe someone can help me ??? the problem lies in where u should put the quotes " "

rst.FindFirst "AttendeeID =" & Me!AttendeeID And "EventID = " & Me!EventID

It works if I hard code it like this
rst.FindFirst AttendeeID=1 And EventID=3

WayneRyan
09-28-2005, 08:26 PM
lim,

Look at FoFa's syntax:

rst.FindFirst "AttendeeID = " & Me.AttendeeID & " And EventID = " & Me.EventID

Wayne