views:

252

answers:

1

Sorry for the lengthy introduction but I think it best to explain the context of my question. I have an Access 2003 database in which users need to create new records based upon pre-existing records already in the table. Some of the users of the database are more familiar with computers in general and create a new record by ...

1. Selecting a previous record in a datasheet and copying it (via right click -> Copy)
2. Selecting new row in the datasheet and "pasting" the previous record (via right click => Paste)
3. Edit the newly pasted row with the new data

This works fine as the table the datasheet is based on uses an "auto-number" field preventing duplicates. The problem I am having is that some of the users of this database are not so "computer-savy" and are having some difficulty with right-clicking etc ... I have been asked to create a button that ..

1. Copies the previous record
2. Inserts it into datasheet

The users can then edit the new record as needed. This leads me to my question. How do I go about copying a record and then inserting it into the datasheet programmatically in VBA? Thanks for any suggestions.

+1  A: 

Use an Append query.

Some notes:

s = "Insert Into TableX (Field1, Field2, Field3) " _
  & "Select Field1, Field2, Field3 From TableX " _
  & "Where ID=" & Forms!TableXForm!ID

CurrentDb.Execute s

Forms!TableXForm.Requery
Remou
Most excellent! Thank you!
webworm