S
steamngn via AccessMonster.com
Hello Gang!
I'm developing (or attempting to, anyway) an ID badge check in module for
class attendance. I have a main form bound to ATTENDANCE_HDR and a subform
bound to ATTENDANCE. The forms are linked on ATT_HDR_ID. In the subform is a
filed for STUDENT_ID. The main form has an OnTimer event to refresh the time
filter so that the check in screen is showing the current class. If I add a
student ID number to the subform STUDENT_ID control and press enter (similar
to what a barcode reader will do), The subform Before Update code pops up a
small confirmation form which closes after a few seconds. All of this is
working fine up until the confirmation form closes. The subform is still on
the current record, and then the main form On Timer event errors out trying
to insert the same record again. How can I get the subform (which loses focus
when the confirmation form opens) to go to a new record after the update?
Also, when a student enters an invalid ID or tries to sign in to the same
class twice, My code sets Cancel = True, but again the subform stays in the
current (Dirty?) record. I am stumped, and sure could use some guidance. Here
is the code for the Before Update on the subfrom:
Private Sub Form_BeforeUpdate(Cancel As Integer)
strSQL = "[STUDENT_ID]=" & Me!STUDENT_ID
strSQL2 = "[STUDENT_ID]=" & Me!STUDENT_ID & " And [ATT_HDR_ID]=" & Me!
ATT_HDR_ID
'check to see if student already signed in
If DCount("STUDENT_ID", "ATTENDANCE", strSQL2) > 0 Then
Cancel = True
'open confirmation form with 0,1,1 openargs
DoCmd.OpenForm "Confirmation", , , , , , "0|1|1"
'If student didn't sign in...
ElseIf DCount("STUDENT_ID", "ATTENDANCE", strSQL2) <= 0 Then
'Check that the Student ID is valid
If DCount("STUDENT_ID", "STUDENTS", strSQL) > 0 Then
RunCommand acCmdRecordsGoToNew
'valid check in-- open confirmation form with data openargs
DoCmd.OpenForm "Confirmation", , , , , , Me!STUDENT_ID & "|" & Me!
EVENT_ST_TIME & "|" & Me!EVENT_DESC
ElseIf DCount("STUDENT_ID", "STUDENTS", strSQL) <= 0 Then
Cancel = True
'Student Id invalid-- open confirmation form with 0,0,0 openargs
DoCmd.OpenForm "Confirmation", , , , , , "0|0|0"
End If
End If
End Sub
Thanks much in advance for any help!
Andy
I'm developing (or attempting to, anyway) an ID badge check in module for
class attendance. I have a main form bound to ATTENDANCE_HDR and a subform
bound to ATTENDANCE. The forms are linked on ATT_HDR_ID. In the subform is a
filed for STUDENT_ID. The main form has an OnTimer event to refresh the time
filter so that the check in screen is showing the current class. If I add a
student ID number to the subform STUDENT_ID control and press enter (similar
to what a barcode reader will do), The subform Before Update code pops up a
small confirmation form which closes after a few seconds. All of this is
working fine up until the confirmation form closes. The subform is still on
the current record, and then the main form On Timer event errors out trying
to insert the same record again. How can I get the subform (which loses focus
when the confirmation form opens) to go to a new record after the update?
Also, when a student enters an invalid ID or tries to sign in to the same
class twice, My code sets Cancel = True, but again the subform stays in the
current (Dirty?) record. I am stumped, and sure could use some guidance. Here
is the code for the Before Update on the subfrom:
Private Sub Form_BeforeUpdate(Cancel As Integer)
strSQL = "[STUDENT_ID]=" & Me!STUDENT_ID
strSQL2 = "[STUDENT_ID]=" & Me!STUDENT_ID & " And [ATT_HDR_ID]=" & Me!
ATT_HDR_ID
'check to see if student already signed in
If DCount("STUDENT_ID", "ATTENDANCE", strSQL2) > 0 Then
Cancel = True
'open confirmation form with 0,1,1 openargs
DoCmd.OpenForm "Confirmation", , , , , , "0|1|1"
'If student didn't sign in...
ElseIf DCount("STUDENT_ID", "ATTENDANCE", strSQL2) <= 0 Then
'Check that the Student ID is valid
If DCount("STUDENT_ID", "STUDENTS", strSQL) > 0 Then
RunCommand acCmdRecordsGoToNew
'valid check in-- open confirmation form with data openargs
DoCmd.OpenForm "Confirmation", , , , , , Me!STUDENT_ID & "|" & Me!
EVENT_ST_TIME & "|" & Me!EVENT_DESC
ElseIf DCount("STUDENT_ID", "STUDENTS", strSQL) <= 0 Then
Cancel = True
'Student Id invalid-- open confirmation form with 0,0,0 openargs
DoCmd.OpenForm "Confirmation", , , , , , "0|0|0"
End If
End If
End Sub
Thanks much in advance for any help!
Andy