How do I parse Multiple DoCcmd statements?

45 pts.
Tags:
DoCmnd
Multiple DoCmnd statements
I am trying to run several DoCmd statements from one button, to go to various Controls and run a macro (the same one each time) which copies the contents of the previous record. The code below works when there is only one pair but when there are two pairs only the second one works. Any suggestions? Many thanks.

Software/Hardware used:
MS Access

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    Your code didn't get pasted. Please add it here in the discussion section.
    70,220 pointsBadges:
    report
  • TRSJ
    Sorry, This is the code: Private Sub Label1104_Click() DoCmd.GoToControl ("Room") DoCmd.RunMacro "CopyPrevious" DoCmd.GoToControl ("Category") DoCmd.RunMacro "CopyPrevious" End Sub What I really want to do, once I have the correct syntax for multiple DoCmd statements above, is to add them to the Current event below (or should it be a BeforeInsert event ?) - so that all new records pick up certain fields from the previous record - how would I do that? Thank you again.
    45 pointsBadges:
    report
  • TRSJ
    It is late - the second piece of code did not get in either! Private Sub Form_Current() If Me.NewRecord Then Me!ForceID = DMax("[D'base ID]", "[Details Master]") + 1 Else Me!ForceID = Me![D'base ID] End If This is needed because the form data comes from a query with several joins and if I do not autocomplete at least one field (ForceID), the autonumber for the record is not generated. End Sub
    45 pointsBadges:
    report
  • carlosdl
    There is no special trick to make any series of commands run sequentially. I guess they are being executed, but the macro is not doing what you want it to do. You could try adding a MsgBox call after the last action, to see if it in fact is being executed twice.
    70,220 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following