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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pasted record automatically exits sub. How continue code?

Status
Not open for further replies.

ag90fox

IS-IT--Management
Mar 14, 2002
17
0
0
US
I've got a button on a form copies a record, using "domenuitem" commands 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:

DoCmd.DoMenuItem acFormBar, acEditMenu, acSelectRecord..
DoCmd.DoMenuItem acFormBar, acEditMenu, acCopy.....
DoCmd.GoToRecord , , acNewRec ...
response = MsgBox("recordcreated", vbYesNo, "verify")
DoCmd.DoMenuItem acFormBar, acEditMenu, 3.. 'paste data...
response = MsgBox("recordpasted", vbYesNo, "verify")

Me.HoursBilled = 0


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 doesn't execute.


Thanks,

Joe
 
What version of Access are you using?

If you are using Access 2000 or above, try using Docmd.RunCommand rather than the DoMenuItem. I honestly have no idea if this will fix the problem, but there is at least a chance, only because Access does weird things sometimes.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top