A form can have many records. Do you always want to duplicate the *first*
one? Sounds odd.
The Load event is too early to try the paste append.
The Current event is also unusable: As soon as you move to any record, if
the code worked, Access would duplicate it which would load the new record
which would fired the Curent event which would copy it and move to the new
record and so the Current event would fire again and... Fortunately for you,
this doesn't work either.
If there is a valid reason for duplicating the first record in the form as
soon as it opens, I am guessing that you are opening the form with a
WhereCondition so that only the one desired record is loaded. If this is the
case, you could OpenForm, and then trigger the Click event of the button so
the code runs automatically. If the command button is named Command1, you
need to remove the Private keyword from the start of this line:
Private Sub Command1_Click( )
You can then execute the code like this:
DoCmd.OpenForm "Form1", WhereCondition: ="ID = 99"
Call Form_Form1.Comm and1_Click
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"2D Rick" <rb*******@comp userve.com> wrote in message
news:11******** *************@j 33g2000cwa.goog legroups.com...
Access2003 in XP
If I open a form to a specific record and click on a command button
with the following code I get a duplcate record:
DoCmd.RunComman d acCmdSelectReco rd
DoCmd.RunComman d acCmdSaveRecord
DoCmd.RunComman d acCmdCopy
DoCmd.RunComman d acCmdPasteAppen d
OR
DoCmd.DoMenuIte m acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuIte m acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuIte m acFormBar, acEditMenu, 5, , acMenuVer70 'Paste
Append
But if I try to run this from and event such as OnLoad, OnCurrent or
OnTimer I get an error message.
"The command or action 'Copy' isn't available now."
I know going in that I what a duplicate record so is there a fix for
this?
Thanks, Rick