A 2013 Duplicate Record VBA (1 Viewer)

Dick7Access

Dick S
Local time
Today, 17:46
Joined
Jun 9, 2009
Messages
4,201
I have a form with a sub form, with a 1 to many. I want to make a duplicate record where I will go into the new record, make some changes, and then save it as a new record. Goggling how to make a duplicate record I cam across the following code:
Code:
Private Sub comand1_Click()
 DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
   DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
   DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70
End Sub
It works good, but doesn't pick up the data in the sub form. What do I need to add to this code to have it pick up the data in the sub form/table?
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 07:46
Joined
Jan 20, 2009
Messages
12,852
DoMenuItem has been deprecated for many years. It is only included for backwards compatibility but should not be used for new designs.

Any code you find that still uses it should be ignored.
 

Mihail

Registered User.
Local time
Tomorrow, 00:46
Joined
Jan 22, 2011
Messages
2,373
Hi Dick !
I don't understand very well what you are trying to do but, in my opinion, is a bad practice to duplicate a record.
My practice is to set the .Default property for controls.
If I make some changes in the new record then Access will save the record.
If not, then I have no need to run code in order to remove (undo) the record.
 

Dick7Access

Dick S
Local time
Today, 17:46
Joined
Jun 9, 2009
Messages
4,201
Hi Dick !
I don't understand very well what you are trying to do but, in my opinion, is a bad practice to duplicate a record.
My practice is to set the .Default property for controls.
If I make some changes in the new record then Access will save the record.
If not, then I have no need to run code in order to remove (undo) the record.

I am trying to automate a list of things to take with me on my trips for meetings. I have been doing this for many year in MS Word. I have a Long trip list usually over three days, and lots of equipment. A short list, three days or under, with no or very little equipment. Each list has a change of date, destination, lodging accommodations, different attire, etc. In Word I have a generic list for long / short. I then save a copy with a different field name and go back in and change all of the above. Removing the few items that will not be needed and adding a few items that are peculiar for that trip. I thought that if I made a generic long / short generic list in Access, and then made a copy of that record I would not only have better record of each trip, have the items alphabetized, and be able to make changes quicker. Repeat trips change very little except for dates and reservation numbers. Hope that is clearer.
 

Dick7Access

Dick S
Local time
Today, 17:46
Joined
Jun 9, 2009
Messages
4,201
Ok, case close
Thanks for all those that tried to help.
I have decided to take a different route. Its probable horrible coding but with my limited coding ability it will have to be. I am going with all the items in there own field with a yes/no. I can than make up one list copy everything in datasheet view and paste it into a new record, change the date, destination, res. number etc. Check the items I want to take, and leave the rest unchecked, and then print a report on that record and I am on my way.
 

Users who are viewing this thread

Top Bottom