SOLVED

Cloning a record works ONLY if I add a MsgBox

Copper Contributor

I have a very simply VBScript that clones a record taken almost step-by-step from an Access Macro.  Here's the copy:

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdRecordsGoToNew
DoCmd.RunCommand acCmdSelectRecord
MsgBox ("Go on")
DoCmd.RunCommand acCmdPasteAppend

 

Without the MsgBox, I get an error that says the Append command isn't available now.  However, if I have the MsgBox and click OK the script runs fine.  What do I need to do so that I don't need the MsgBox?  I can't figure out why it's throwing the error without the message box.  Ideas?

3 Replies
This might be a case where DoEvents could make a difference.

@Tom_van_Stiphout Great Idea!  I hadn't thought of that.

best response confirmed by demaionewton (Copper Contributor)
Solution
Did a bit of research and found that I don't need the 2 lines:
DoCmd.RunCommand acCmdRecordsGoToNew
DoCmd.RunCommand acCmdSelectRecord
These don't seem to be necessary. Removing them and the MsgBox eliminates the bug.
1 best response

Accepted Solutions
best response confirmed by demaionewton (Copper Contributor)
Solution
Did a bit of research and found that I don't need the 2 lines:
DoCmd.RunCommand acCmdRecordsGoToNew
DoCmd.RunCommand acCmdSelectRecord
These don't seem to be necessary. Removing them and the MsgBox eliminates the bug.

View solution in original post