Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I duplicate a record 1

Status
Not open for further replies.

asinarrgh

Programmer
Apr 2, 2003
9
SK
My table is a list of folks who have registered for an event. It is normal for a husband and wife (and maybe child) to register on the same form. I would like to enter all of the data for the first person, then press a button to duplicate the data for the next registrant included in that envelope. The only data that would change would be the registration number and maybe the events attended.
I used the control button wizard to create the button which yielded the following code:

[I add code here to generate the next registration number]

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70
[I set the registration number.value to the number I generated above]

The registration number is a mandatory field, and the primary index (I want to control which numbers starts the registration numbers).
I use control buttons to perform all record navigation.

When I press the duperec button, I get all blank text boxes eexcept for the registration number textbox which is properly incremented.
What am I doing wrong? I have even tried to set the registration field to non-indexed and also to indexed but allow duplicates, all with the same results.
Thanks
 
I assume you have separate code which is developing the Registration number.

The macros that you are using cannot do what you hope they can do!
acEditMenu item 8 is select all
2 is cut
5 is paste special
this would imply you want to copy all of the fields on the form and paste them to the blank you bring up......
I'm pretty sure that won't happen!!!

You could save each field to a variable and then send the variables back to the new form or...

you could interrogate the table for the last record entered then add a new record and copy that information in then bring to screen to edit as required.

 
I understand about creating variables to hold all of the values of the text boxes on the form... I COULD do that, I just thought there would be a way to do it without so much code (that is 41 variables and assignment statements).

I do not understand what you mean about "interrogate the table". Is this an ADO process?

Yes, I do generate the registration number right after the button is pressed.

I have just done a little more research and IF I have the table open AND I have "copied" a record, the 8th item on the table editmenu is "Paste Append". Is there a way to designate that I want the "Select" then "Copy" and then "Paste Append" from the table menu in the code for the "duplicate record" "OnClick" event?
Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top