Code to stop duplicate entries (1 Viewer)

Jade

Registered User.
Local time
Today, 11:02
Joined
Jun 15, 2001
Messages
24
I have created a database and one of the forms is a time sheet form that keeps track of employees time. I need to write code to stop employees from entering time in twice on the same day. For example, John enters time for todays date, then forgets that he entered the time in and enters it in again. I need to write code to say if John already has entered in his time today, a message comes up and states that his time is already entered.

Please help.
 

HarmonyGirl

Registered User.
Local time
Today, 11:02
Joined
Mar 12, 2001
Messages
19
If I understand your request correctly, I have a suggestion that might work for you.

If you reverse the logic, and alert the user if they have not entered time for that day, that might be more intuitive.

If you take this route, insert this code into an Event Procedure on your form's On Open event:

If IsNull([Forms]![frmname]![pick a field name that you want to test if it is null]) Then
DoCmd.Close acForm, "frmname"
MsgBox ("Insert your message here.")
ElseIf ([Forms]![frmname]![same field but if it is not null]) Then
DoCmd.Maximize
End If

What this code does is it checks a field that you specify is null, and if it is, a message box appears. If it is not null, the form will be maximized and no message box will appear. Of course, you could change this around to suit your needs, either on the initial logic or the ElseIf (last action) statement.

HTH
 

Users who are viewing this thread

Top Bottom