Creating a duplicate table entry via form

hardrock

Registered User.
Local time
Today, 19:46
Joined
Apr 5, 2007
Messages
166
A record is created in my table (TEST Data) when i hit the save button on my form.

The record is created, and the suppliers name as an example is "Phils Cables", now i want to automatically create a duplicate record in my table with the same information i just saved, the only difference being the new record will have a new Supplier name "Steves Cables".I've had a go solving the problem with the code below, but im stuck cause it don't seem to work.

So in summary, two records exactly the same, apart from the second record has a different supplier name, which will only be "Steves Cables" Anyone ?
***********************************
'Code to duplicate last saved record, but with different supplier name
Dim dbs As DAO.Database
Dim testdata As DAO.Recordset

Set dbs = CurrentDb
Set testdata = dbs.OpenRecordset("TEST Data")

With testdate
.AddNew
[Supplier] = "Steves Cables"
[Part No] = Me.PartNo
[Issue No] = Me.IssueNo
[Address] = me.address
[Phonenum] = me.phone
.Update
.Close
End With
 
Last edited:
re:

Please any ideas. I have searched the forum for a answer.
 
I would also be interested in the answer to this.
 
This is one way to do it. Create public variables in a standard module for each of the fields. In the Before Update event of the form (if using a bound form) set the values of the variables and then in the On Current event you can test to see if the field, or fields, is/are empty and if so populate it with the contents of the variable.
 

Users who are viewing this thread

Back
Top Bottom