Problem: For Loop to add new records to a recordset?

T

tclarke

Hi,

I'm using Access 2003 and VB 6.3 to set exams and track progress. I've
created a command button on a form (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 the form to automatically add a new record whenever a
resit is required.

Is there any way to add code to this button which will search each
record in the RecordSet, when it is not empty, find out if the record's
control (Me.chbxResit) is True and if so, add a new record and copy the
Me.txtModuleID value into the new record.

N.B. An added complication is that up to three resits are allowed for
each module.

Terry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top