Using Access 2000
The form is called frmMakeupMeetings. It's a data entry form to record member attendance at makeup meetings (meetings separate from Regular meetings).
The form is opened from another form, frmAttendance, by a command button. When the command button on frmAttedance is clicked, it inserts the date in a text box, txtMeetingDate, on frmMakeupMeetings.
Also on the form are 2 list boxes. One is lstMembers from which the user selects 1 member. The second is lstMakeupType from which the user selects 1 makeup type.
Then a command button is pressed to Post the selection.
Following is the code behind the Post button, cmdPost
This inserts the MemberID from lstMemberID, the Makeup Type from lstMakeupType, "Makeup Meeting" (to differentiate between a Regular meeting, as regular meetings are kept in the same table but entered from frmAttendance), and True (to check a Present Yes/No box as true.
What happens is that 2 entries are made in tblAttendance when the Post button is pushed. The first entry is accurate. The second entry has the same member number, the same Makeup Type, but the Present Yes/No is not checked and the "Makeup Meeting" is not entered in the Meeting Type in tblAttendance.
Can anybody spot anything in the code that is causing the double entry?
Thanks.
Tom
The form is called frmMakeupMeetings. It's a data entry form to record member attendance at makeup meetings (meetings separate from Regular meetings).
The form is opened from another form, frmAttendance, by a command button. When the command button on frmAttedance is clicked, it inserts the date in a text box, txtMeetingDate, on frmMakeupMeetings.
Also on the form are 2 list boxes. One is lstMembers from which the user selects 1 member. The second is lstMakeupType from which the user selects 1 makeup type.
Then a command button is pressed to Post the selection.
Following is the code behind the Post button, cmdPost
Code:
Private Sub cmdPost_Click()
On Error GoTo Err_cmdPost_Click
Dim sql As String
If IsNull(Me.txtMeetingDate) Then
MsgBox "Record cannot be saved without a Makeup Date!" _
& vbCrLf & "Returning to Attendance form.", vbExclamation, "Makeup Date required."
Me.Undo
Exit Sub
Call cmdClose_Click
End If
If IsNull(Me.lstMemberID) Then
MsgBox "Please select Member from list.", vbExclamation, "Member needed"
Me.lstMemberID.SetFocus
Exit Sub
ElseIf IsNull(Me.lstMakeupType) Then
MsgBox "Please select Makeup Meeting Type from list.", vbExclamation, "Makeup Meeting Type needed"
Me.lstMakeupType.SetFocus
Exit Sub
End If
sql = "INSERT INTO tblAttendance(MemberID, MeetingDate, Present, TypeOfMeeting,MakeupType) VALUES(Forms!frmMakeUpMeetings!lstMemberID , #" & Me.txtMeetingDate & "#, True,""Makeup Meeting"",Forms!frmMakeUpMeetings!lstMakeupType)"
DoCmd.RunSQL sql
Dim Response As Variant
Dim Response2 As Variant
Dim MyDate As Date
Response = MsgBox("Do you wish to Post another Makeup Meeting?", vbYesNo, "Posting check")
If Response = vbYes Then
Response2 = MsgBox("For the SAME Date or a DIFFERENT Date?" _
& vbCrLf & vbCrLf & "If SAME Date select <Yes>, if DIFFERENT Date select <No>.", vbYesNo, "Same or Different Date check")
If Response2 = vbYes Then
MyDate = Me.txtMeetingDate
Me.txtMeetingDate = MyDate
Me.lstMemberID = Null
Me.lstMakeupType = Null
Me.lstMemberID.SetFocus
Else
MsgBox " Please enter desired date..." _
& vbCrLf & "Then select Member and Makeup Meeting Type.", vbInformation, "Entries needed"
Me.txtMeetingDate.Enabled = True
Me.txtMeetingDate = Null
Me.lstMemberID = Null
Me.lstMakeupType = Null
Me.txtMeetingDate.SetFocus
End If
Else
DoCmd.Close
End If
Exit_cmdPost_Click:
Exit Sub
Err_cmdPost_Click:
MsgBox Err.Description
Resume Exit_cmdPost_Click
End Sub
This inserts the MemberID from lstMemberID, the Makeup Type from lstMakeupType, "Makeup Meeting" (to differentiate between a Regular meeting, as regular meetings are kept in the same table but entered from frmAttendance), and True (to check a Present Yes/No box as true.
What happens is that 2 entries are made in tblAttendance when the Post button is pushed. The first entry is accurate. The second entry has the same member number, the same Makeup Type, but the Present Yes/No is not checked and the "Makeup Meeting" is not entered in the Meeting Type in tblAttendance.
Can anybody spot anything in the code that is causing the double entry?
Thanks.
Tom