T
tclarke
Hi,
I'm using an Acess 2003 database and VB 6.3. I have a form which
displays individual student personal details in the Main Form and
individual student exam modules taken in the Sub Form. The Sub Form is
diaplayed as Continuous Forms and includes records of exam modules
passed and exam modules failed.
The Main Form is named ExamFrm - (Record Source StudentTbl), and the
Sub Form is named Exam_details_Subform - (Record Source - ExamTbl).
I have Command Buttons and Combo Boxes on different forms in the
database which open the ExamFrm and these all work OK.
For the purposes of this database, each student is always assigned 8
exam modules so I don't want the user to have to set these manually. I
want to create 8 new records automatically with ModuleID's of 1 To
8...but only if the recordset is empty.
The code I devised below creates only one new record when
txtModuleID(Sub Form)has no data...but it always assigns the value of
the last instruction. Can you Help?
Private Sub Form_Open(Cancel As Integer)
If IsNull(Me.Exam_details_Subform!txtModuleID) Then
Me.Exam_details_Subform.Form.RecordsetClone.AddNew
Me.Exam_details_Subform!txtModuleID = 1
Me.Exam_details_Subform.Form.RecordsetClone.AddNew
Me.Exam_details_Subform!txtModuleID = 2
' etc for 8 new records
End If
End Sub
Terry
I'm using an Acess 2003 database and VB 6.3. I have a form which
displays individual student personal details in the Main Form and
individual student exam modules taken in the Sub Form. The Sub Form is
diaplayed as Continuous Forms and includes records of exam modules
passed and exam modules failed.
The Main Form is named ExamFrm - (Record Source StudentTbl), and the
Sub Form is named Exam_details_Subform - (Record Source - ExamTbl).
I have Command Buttons and Combo Boxes on different forms in the
database which open the ExamFrm and these all work OK.
For the purposes of this database, each student is always assigned 8
exam modules so I don't want the user to have to set these manually. I
want to create 8 new records automatically with ModuleID's of 1 To
8...but only if the recordset is empty.
The code I devised below creates only one new record when
txtModuleID(Sub Form)has no data...but it always assigns the value of
the last instruction. Can you Help?
Private Sub Form_Open(Cancel As Integer)
If IsNull(Me.Exam_details_Subform!txtModuleID) Then
Me.Exam_details_Subform.Form.RecordsetClone.AddNew
Me.Exam_details_Subform!txtModuleID = 1
Me.Exam_details_Subform.Form.RecordsetClone.AddNew
Me.Exam_details_Subform!txtModuleID = 2
' etc for 8 new records
End If
End Sub
Terry