Adding records in a form based on a recordsetclone from another fo

G

Guest

Friends,

I run into a strange behavior in Access 2003 when trying to add records into
a form based on a recordsetclone from another form. The scene is this. In a
page I have two subforms. The firsm subform contains information (primary
keys and foregin keys) that I want to copy into the other form before letting
the user att additional informatin in this form. The code is like this:

Dim rstPersonnel As Recordset
Set rstPersonnel = Me.fDPRPersonnelReport.Form.RecordsetClone

iDPRReportId = Me.dpr_report_id
With Me.fAssignedPersonnel.Form.RecordsetClone
If Not (.BOF And .EOF) Then
.MoveLast
iCounter = .RecordCount
.MoveFirst
While Not .EOF
rstPersonnel.AddNew
rstPersonnel.Fields("dpr_report_id") = iDPRReportId
rstPersonnel.Fields("resources_id") =
..Fields("resources_id")
rstPersonnel.Fields("number_of_persons") =
..Fields("number_of_units")
.MoveNext
Wend

End If
End With

Then the strange thing happens that the last record in the from - clone is
not inserted into the to - clone. Can anybody help me with a solution?

Leif S. (Norway)
 
M

Marshall Barton

Leif said:
I run into a strange behavior in Access 2003 when trying to add records into
a form based on a recordsetclone from another form. The scene is this. In a
page I have two subforms. The firsm subform contains information (primary
keys and foregin keys) that I want to copy into the other form before letting
the user att additional informatin in this form. The code is like this:

Dim rstPersonnel As Recordset
Set rstPersonnel = Me.fDPRPersonnelReport.Form.RecordsetClone

iDPRReportId = Me.dpr_report_id
With Me.fAssignedPersonnel.Form.RecordsetClone
If Not (.BOF And .EOF) Then
.MoveLast
iCounter = .RecordCount
.MoveFirst
While Not .EOF
rstPersonnel.AddNew
rstPersonnel.Fields("dpr_report_id") = iDPRReportId
rstPersonnel.Fields("resources_id") =
.Fields("resources_id")
rstPersonnel.Fields("number_of_persons") =
.Fields("number_of_units")
.MoveNext
Wend

End If
End With

Then the strange thing happens that the last record in the from - clone is
not inserted into the to - clone.


You forgot the rstPersonnel.Update
 
G

Guest

Marsh. That solved my problem. I had tried with .Update but did not see that
I then tried to update the Clone that was pointing to EOF (fAssignedPersonnel)

Thanks a lot!

/L
 
Top