Compare new record with existing

sparlaman

Registered User.
Local time
Today, 17:51
Joined
Feb 10, 2005
Messages
17
My database tracks employee training.

I have tblClasses, tblEmployees, and tblRegistrations. I have a registration
form with EmpName and subformClasses, which allows me to register one
employee for several classes at a time.

My registration form has an OK button. I need a message to appear (on btnOK click) before adding a new record to the registrations table that indicates if the employee has already had training for the one or more of the classes selected in the subform. Then the option to "Yes" add the record anyway, or "No" cancel the record.

I have everything working except, I can’t figure out how to do the
comparison with the subform and generate my "Yes/No" option. I’m hoping that one of you wonderful access geniuses will have a relatively simple suggestion for me.

--
Thanks in advance!
Shel
 
Elaborate?

Thanks for you response.
DLookup isn't a function that I'm very familiar with. Could you please elaborate on the syntax and where to apply the code?

Thanks,
Shel
 
DLookup is used to look up data in a table or query.

DLookup(Data,Name of table,criteria) Look in the help file for more detailed information.

Here is an example:
Code:
UserName = DLookup("[UserName]", "tblClasses", "[ClassID] = " & txtClassID.Value & " And [UserName] = """ & txtUser.Value & """")

If nothing matchs the criteria you specified it will be Null.

So put the above line after your click event for your OK button.

Then put:
Code:
If IsNull(UserName) Then
    ' Put code to add data
Else
    ' Put a MsgBox to let the user know the class has already been added.
End If

Hope that helps.
 

Users who are viewing this thread

Back
Top Bottom