Data type error 3421

  • Thread starter Thread starter Darlene Boran via AccessMonster.com
  • Start date Start date
D

Darlene Boran via AccessMonster.com

I have an Access database in XP and am trying to duplicate a record on a form with a query. There are several records showing from the query, I have place a control button to duplicate the record showing and create a new record. The record has an autonum key and when I try creating the new record using a recordsetclose, I get the above error message. I have a reference to DAO Library 3.6 Object Library and I defined the recordset as rst.DAO.Recordset. I am using an AddNew.
If I use an "With recordset .Open "tablename",Current Project.Connection, . . . it works but gives me a duplicate of the last record instead of the one I am currently looking at. How can I present the duplicated record in the form for editing? Thanks for any input. Darlene
 
Please post the entire code steps that you're currently trying to use.

Are you wanting to create a new record whose fields have the same data as
the one being displayed at that moment (or the one that has the focus if
it's a continuous forms view?) except for the autonumber field?
 
Hi Darlene, this code works for me:

Private Sub cmdAddRecord_Click()

Dim rst As DAO.Recordset
Set rst = Me.RecordsetClone
rst.AddNew
' Get values from current selected record
rst("Section") = txtSection & "_NewRec"
rst.Update

End Sub

Note: if you try to insert a value to the AutoNumber field then you will run
into problems.
What is the text of the error you're receiving.

HTH, Graeme.
 
Back
Top