T
tclarke
Hi,
I've created a command button on a subform (continuous forms) which
runs the code below in it's On_Click event. It adds 8 new records if
the RecordSet is empty. It also assigns a value to each
(Me.txtModuleID) control and it works just fine.
Private Sub cmdSetExams_Click()
Dim i As Long
With Me.Recordset
If .EOF = True And .BOF = True Then
For i = 1 To 8
Me.Recordset.AddNew
Me.txtModuleID = i
Next
End If
End With
End Sub
I would like dispense with the command button and get the subform to
automatically add 8 new records to the recordset in the OnCurrent Event
whenever the RecordSet is empty.
But when I put the above code in the OnCurrent event of the subform it
continually adds multiple records, each containing the value 1 for
txtModuleID and crashes. Can you help?
N.B. the Main form (ExamFrm)is linked to StudentTbl and the subform
(Exam_details_Subform) is linked to ExamTbl. The two tables have a
relationship based on the field LogBookNo.
I've created a command button on a subform (continuous forms) which
runs the code below in it's On_Click event. It adds 8 new records if
the RecordSet is empty. It also assigns a value to each
(Me.txtModuleID) control and it works just fine.
Private Sub cmdSetExams_Click()
Dim i As Long
With Me.Recordset
If .EOF = True And .BOF = True Then
For i = 1 To 8
Me.Recordset.AddNew
Me.txtModuleID = i
Next
End If
End With
End Sub
I would like dispense with the command button and get the subform to
automatically add 8 new records to the recordset in the OnCurrent Event
whenever the RecordSet is empty.
But when I put the above code in the OnCurrent event of the subform it
continually adds multiple records, each containing the value 1 for
txtModuleID and crashes. Can you help?
N.B. the Main form (ExamFrm)is linked to StudentTbl and the subform
(Exam_details_Subform) is linked to ExamTbl. The two tables have a
relationship based on the field LogBookNo.