Empty Recordset


G

Guest

Hello,

I have the following problem and was wondeing if anyone can help me.
On a form, I have a subform with records. Double clicking on a record in
this subform calls a new form (form2), showing the record in detail.
When I close this form and double click the same or another record, the form
(form2) opens again, but this time it is completely blank, even the fields
are not shown.

This is the code:

Private Sub Form_DblClick(Cancel As Integer)
Set rs1 = Form_Records.RecordsetClone
Set rs2 = CurrentDb.OpenRecordset("Table")
Do Until rs1.EOF
rs2.AddNew
rs2!field1= rs1.field1
rs2!field2 = rs1.field2
rs2!field3 = rs1.field3

rs2.Update
rs1.MoveNext
Loop
rs1.Close
rs2.Close

DoCmd.OpenForm "form2", acNormal
......etc
End sub

If form2 is closed, the table in which the recordset is stored, is emptied.
Double clicking a record in the subform, does not execute the code above (at
least not the code between Do Until... til ...Loop)
The table for the recordset stays empty and the form is blank.
It works again when the form and subform are reopend and this is not what I
want.

Is there a solution?

Greetings
René
 
Ad

Advertisements

G

Guest

It appears your code is running when the "subform" itself is double-clicked
Private Sub Form_DblClick(Cancel As Integer)

try moving the code to the sub-forms record 'on-double-click' event.
 
G

Guest

Thanks, but it did not solve my problem

rolaaus said:
It appears your code is running when the "subform" itself is double-clicked

try moving the code to the sub-forms record 'on-double-click' event.
 
Ad

Advertisements

G

Guest

My problem is solved by adding line
Form_Records.RecordsetClone.MoveFirst
after line
Set rs1 = Form_Records.RecordsetClone
 

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