I've got a button on a form copies the current record into a new record, using "runcommand" in the the following sequence:
1. select record
2. copy record
3. goto new record
4. paste record
That works fine. Next, within the the same sub I want to change a few of the fields on that form, but I've found that the sub quits executing the code right after the paste command. I don't know if its automatically exiting the subprocedure, but I need the subprocedure to continue so I can change the field values. Can someone recommend a way to do this?
Code:
Private Sub cmdResub_Click()
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.GoToRecord , , acNewRec
response = MsgBox("recordcreated", vbYesNo... used this to verify code runs to this point
DoCmd.RunCommand acCmdPaste
-----code stops running here-----
response = MsgBox("recordpasted", vbYesNo, "verify")
Me.HoursBilled = 0
Me.AssignedDate = now()
End sub
The way I found this out is by using msgbox's as flags. The MSGBOX function on line 4 executes, but the MSGBOX on line 6 and anything after doesn't execute.
Thanks,
Joe
1. select record
2. copy record
3. goto new record
4. paste record
That works fine. Next, within the the same sub I want to change a few of the fields on that form, but I've found that the sub quits executing the code right after the paste command. I don't know if its automatically exiting the subprocedure, but I need the subprocedure to continue so I can change the field values. Can someone recommend a way to do this?
Code:
Private Sub cmdResub_Click()
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.GoToRecord , , acNewRec
response = MsgBox("recordcreated", vbYesNo... used this to verify code runs to this point
DoCmd.RunCommand acCmdPaste
-----code stops running here-----
response = MsgBox("recordpasted", vbYesNo, "verify")
Me.HoursBilled = 0
Me.AssignedDate = now()
End sub
The way I found this out is by using msgbox's as flags. The MSGBOX function on line 4 executes, but the MSGBOX on line 6 and anything after doesn't execute.
Thanks,
Joe