-
Apr 25th, 2006, 07:22 AM
#1
Thread Starter
New Member
Paste command in Access form code exits subroutine. Don't make no sense!
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? Does it make sense that it dumps out of this code after the paste instead of continuing with the rest of the code?
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. I also included an error checking subroutine that returned no errors.
Thanks,
Joe
-
Apr 25th, 2006, 07:51 AM
#2
Re: Paste command in Access form code exits subroutine. Don't make no sense!
Put a break at the beginning of the event and step through to see what is actually happening.
-
Apr 25th, 2006, 08:57 AM
#3
Thread Starter
New Member
Re: Paste command in Access form code exits subroutine. Don't make no sense!
Not too sure how to do what you're asking. how do you put a break in? thanks!
Joe
-
Apr 25th, 2006, 09:34 AM
#4
Re: Paste command in Access form code exits subroutine. Don't make no sense!
Are you running this in VB6 or in Access?
-
Apr 25th, 2006, 09:35 AM
#5
Thread Starter
New Member
Re: Paste command in Access form code exits subroutine. Don't make no sense!
MS Access 2003. Its visual basic underlying a command button on a form.
-
Apr 25th, 2006, 09:39 AM
#6
Re: Paste command in Access form code exits subroutine. Don't make no sense!
added code tags for easier reading...
VB 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
to add a breakpoint just click the column next to the line.. a dot will appear and the line will get highlighted.
then whe u run the code it will stop there... use F8 to step one line at a time
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 25th, 2006, 09:59 AM
#7
Thread Starter
New Member
Re: Paste command in Access form code exits subroutine. Don't make no sense!
Tried that. highlighted the line in red with the dot to the left. saved the form, opened the form, pressed the comand button and the code ran through without pausing at all, of course without executing the code past the accmdpast line.
-
Apr 25th, 2006, 10:02 AM
#8
Re: Paste command in Access form code exits subroutine. Don't make no sense!
dont save/close.. highligh then run... closing it will erase breakpoints
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 25th, 2006, 10:08 AM
#9
Thread Starter
New Member
Re: Paste command in Access form code exits subroutine. Don't make no sense!
Man, I can't win for losing! I went in, set the breakpoints, minimized the code window, went to form view, pressed the comman button and it still went all the way through the code to the paste event where it quits.
I'm really not trying to make this difficult!)
-
Apr 25th, 2006, 10:15 AM
#10
Re: Paste command in Access form code exits subroutine. Don't make no sense!
hmmm...
I guess u will need to use another method..
like using an INSERT query
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|