Need Help Using DoCmd.DoMenuItem To Copy A Record




I appreciate the help in advance. I have a form, "Form A", where a user
enters information into several fields. "Form A" has a subform in it,
"Subform B". "Subform B" also has several fields where a user enters

I then added a command button that is suppsoed to select the record, copy,
and then paste all the data into a new record. However, when the command
button is clicked on information from Form A is copied and pasted. I dont'
know why it is not copying any information from my subofrm B.

The current code I have is the following:

Private Sub Command54_Click()
On Error GoTo Err_Command54_Click

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append

Exit Sub

End Sub




Looks like something the wizard generated, which for some reason still uses
the dreadful DoMenuItem syntax. Help says DoMenuItem is for backward
compatability, but then it uses it for new code. Conversions to RunCommand
(and other helpful information) here:

However, no matter the syntax, it will not copy the subform records. For
Purchase Orders we often need to copy most of an old purchase order,
including line items listed in the subform, but with a new date and a few
other details changed. For that I use Allen Browne's code for duplicating
the records in form and subform:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question