no matching records (1 Viewer)

jenntheblond

Registered User.
Local time
Today, 20:02
Joined
May 9, 2001
Messages
15
Hi. I have a form which tracks courses and instructors and students enrolled. The student subform is based on a query which is based on two tables: one with basic student info, and the other with course/credit info. When i type in an ID number, it pulls up student info.
However, when the student is a new one, it gives me an error. I need a way for the form to give a msg when the ID # is not found saying something like "student is new, do you want to enter?" then take me to a pop-up form for student info data entry. Then take me back to the main form/subform with the correct/updated info.
I am very very new/bad at code so please be specific here. thanks.
 

Jack Cowley

Registered User.
Local time
Today, 20:02
Joined
Aug 7, 2000
Messages
2,639
In the Before Update event of the Text box that you type the StudentID into put this code:

If IsNull(DLookup("StudentID", "TableName", "[StudentID]= " & Me.TextBoxName)) Then
MsgBox "This ID is not valid"
Cancel = True
End If

Replace the TableName with the table that has the StudentsID and the TextBoxName with the name of the field where you enter your StudentID. And in the code above I have assumed that the StudentID is a number and not text. If it is text then the code would be:"[StudentID]= '" & Me.TextBoxName & "'".

[This message has been edited by Jack Cowley (edited 06-20-2001).]
 

Users who are viewing this thread

Top Bottom