DLookup

M

Mark

Hi,

Would something like "dlookup" work for the following????

I need some assistance with part of my class registration
form. I have a class registration form, in which
employees can enroll in various classes. Upon filling out
a few fields in the form the user can click a command
button that will save the record in a table. I have an
if statement in the event procedure of the command
control/button that prompts the user of a few things,
such as if certain fields are not filled out, before being
able to save the record/class enrollment. I would also
like to "not" allow an employee to register for a class
more than once. If an employee has registered for a class
can I just add something in the "if" statement of the
click command procedure to check if the "ClassID"
and "EmployeeID" are found in the "Class Registration
Table"... thus not allowing duplicate enrollments? As in
something like below:


ElseIf (Me.ClassID) = (Tables!
tableClassRegistration.ClassID) And (Me.EmployeeID) =
Tables!tableClassRegistration.EmployeeID) Then
MsgBox "You have already registered for this class, please
choose another class to enroll in or exit this form."
Me.ClassID.SetFocus


I would probably need to use both of the identifiers to
accomplish this.

Thanks for helping me out with this!!!!!!!!.
 
M

Mike Painter

Mark said:
Hi,

Would something like "dlookup" work for the following????

I need some assistance with part of my class registration
form. I have a class registration form, in which
employees can enroll in various classes. Upon filling out
a few fields in the form the user can click a command
button that will save the record in a table. I have an
if statement in the event procedure of the command
control/button that prompts the user of a few things,
such as if certain fields are not filled out, before being
able to save the record/class enrollment. I would also
like to "not" allow an employee to register for a class
more than once. If an employee has registered for a class
can I just add something in the "if" statement of the
click command procedure to check if the "ClassID"
and "EmployeeID" are found in the "Class Registration
Table"... thus not allowing duplicate enrollments? As in
something like below:


ElseIf (Me.ClassID) = (Tables!
tableClassRegistration.ClassID) And (Me.EmployeeID) =
Tables!tableClassRegistration.EmployeeID) Then
MsgBox "You have already registered for this class, please
choose another class to enroll in or exit this form."
Me.ClassID.SetFocus

You could do that but setting the EmployeeID and classID fields as a key
would do the same thing and you would not have to worry about forgetting the
code when you created another table.
 
M

Mark

Hey Mike or anyone else,

Making the "ClassID" and "EmployeeID" fields in
the "ClassRegistration" table as Primary Keys does the
trick. Thanks!!!

I have a follow-up question. When I tested the form out
(tried to enroll an Employee into a Class that was already
enrolled in that particular class)... I got the standard
Access dialog box which is really wordy. Can/how would I
go about rewording this message box? Would the only way
to have a more friendly msgbox appear would be to have a
second message box appear after the user closes the
standard msgbox?

Many thanks!!!!!!!!!
 
M

Mike Painter

Mark said:
Hey Mike or anyone else,

Making the "ClassID" and "EmployeeID" fields in
the "ClassRegistration" table as Primary Keys does the
trick. Thanks!!!

I have a follow-up question. When I tested the form out
(tried to enroll an Employee into a Class that was already
enrolled in that particular class)... I got the standard
Access dialog box which is really wordy. Can/how would I
go about rewording this message box? Would the only way
to have a more friendly msgbox appear would be to have a
second message box appear after the user closes the
standard msgbox?

Many thanks!!!!!!!!!
Tell them that they broke the computer and are fired.
Failing that you can use doCmd.Setwarnings false and use onError to post
your own message.
 
M

Mark

Mike, I like your answer to my follow-up question... I
like the way you think! Moreover, thanks for the
assistance!!! Have a good one over there!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top