DAO Empty Recordset "No Current Record"

  • Thread starter Thread starter John
  • Start date Start date
J

John

I'm trying to use DAO to pre-create records on a form to an empty updateable
recordset. Later the user will fill in one value field in each record.
(My KeyField uses a defaultvalue of =NZ(DMax("[DefectID]","tblDefects"),0)+1
to generate a key value)

Private Sub cmdSetup_Click()
Dim Rst As DAO.Recordset
Set Rst = Form.RecordsetClone
Rst.AddNew
Rst.Edit
Rst("LengthM") = 100
Rst.Update
End Sub

I've tried, .MoveFirst, .AddNew, but they generate an "No Current Record"
error.

How can I get to that first new record to Edit and Update with my values?

Thanks,
John
 
Hi John

Delete the line that says Rst.Edit.

The Edit method is for modifying *existing* records. AddNew adds a new
record *and* puts it in a state for editing.
 
Graham,
Thanks a lot. Works like a champ!
Found a lot of associated hits on this in the Google groups, but no one laid
it out quite so clearly.
John

Graham Mandeno said:
Hi John

Delete the line that says Rst.Edit.

The Edit method is for modifying *existing* records. AddNew adds a new
record *and* puts it in a state for editing.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

John said:
I'm trying to use DAO to pre-create records on a form to an empty
updateable recordset. Later the user will fill in one value field in
each record. (My KeyField uses a defaultvalue of
=NZ(DMax("[DefectID]","tblDefects"),0)+1 to generate a key value)

Private Sub cmdSetup_Click()
Dim Rst As DAO.Recordset
Set Rst = Form.RecordsetClone
Rst.AddNew
Rst.Edit
Rst("LengthM") = 100
Rst.Update
End Sub

I've tried, .MoveFirst, .AddNew, but they generate an "No Current Record"
error.

How can I get to that first new record to Edit and Update with my values?

Thanks,
John
 
Back
Top