In the Before Update event of the text box where you enter the date:
If Not IsNull(DLookup("[AttendanceDate]", "YourTableName", "[AttendanceDate]
= #" & Me.txtAttendanceDate & "#" Then
MsgBox "Attendance for " & Me.txtAttendanceDate & " Already Recorded"
Cancel = True
End If
[AttendanceDate] is the name of the field where the date is carried
YourTableName is the name of the table where the date is carried
Me.txtDate is the name of the text box control where you enter the date.
The code above will check to see if the date is already recorded. If the
DLookup does not return Null, that means the date is recorded. If so, the
message box will be displayed, the update will be canceled, and the cursor
will remain in the date control.
JPol said:
All works great, Now next question?
Ned some help setting up the form. Have two tables:
1. Students Form and Demerits Form joined one to many
2. The demerit form is a subform with Date and I’ve placed the Option Group
box on the sub-form that has 3 buttons Present, Absent, Absent Unexcused.
When I press any of the choices I would like for the user to be unable to
duplicate the date of the attendance for the particular student. Say on
5/5/05 John Doe can be either Present, Absent or Absent Unexcused. Right now
I am able to enter records with the same date with different Option Group
choice causing duplicate date entry. Any help. Appreciate.
JPol
:
On Fri, 26 May 2006 11:23:01 -0700, JPol wrote:
On my form I have an option group[Frame25] set to Present(1), Absent(2),
Unexcused(3). Present is a default. There are other fields on the form that I
would like to behave depending on which option in an Option Group was chosen.
If I know how to program one of the them then Iʽll repeat the procedure for
others in like manner.
The field [StaffNr] needs to do the following:
If Frame25= Present then default, If Absent=[HomeroomNr], if unexcused then 0
JPol
Code Frame25 AfterUpdate event:
If Me![Frame25] = 1 Then
[StaffNr] = [StaffNr].defaultvalue
Elseif Me![Frame25] = 2 then
[StaffNr] = Me![HomeroomNr]
Else
[StaffNr] = 0
End If