check for records in table

human_anomaly

Registered User.
Local time
Yesterday, 23:08
Joined
Apr 12, 2004
Messages
69
I want to write an If statement that will, for example: check table1 to see if any records in field1 are equal to a variable.
Does anyone know how I would go about this.
 
Last edited:
SELECT [table1].field1,
FROM [table1]
WHERE [table1].field1])=[variable?]));
 
so how would i put that into an if statement?
 
Where do you want to call this from and what will it achive?

Do you want a function to be performed IF there are records in table 1, feild 1 that match the variable?

Are you putting the variable into a textbox on a form?
 
this is what I have tried:
If "SELECT [DataTbl].student FROM [DataTbl] WHERE [DataTbl].student] = '" & Me.Student.Value & "' " Then
I want it to execute code if there is a student that has the same name as the variable.
 
Solution

I found that this worked:
If DLookup("Student", "DataTbl", "Student = '" & Me.Student.Value & "'") > 0 Then
 

Users who are viewing this thread

Back
Top Bottom