Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2005

    Unanswered: Pausing code execution

    I am trying to figure out how to pause a code execution until a user clicks a button on a subform.

    to make a long story short, a user will click a button on the subform to delete a record, it should then change the source object of the subform to open a new form so they can enter a reason for the deletion. then once they say ok or cancel, change the source object back to the form before and finish executing the code (which is to send an email out). what it is doing now is executing the email code and then going to the reason for deletion subform instead of vice versa. i've tried setting focus to the subform but it still continutes to do the same thing.

    any help is appreciated!

  2. #2
    Join Date
    Nov 2003
    Open your Reason form as a Dialog form. Code will not run after the line that initiates the Dialog Form untill the Dialog form is closed. Have the Dialog Form upon closing, to set the Tag property of the calling SubForm to indicate whether or not the Cancel button was selected.

    In the SubForm's Command Button OnClick event:
    Private Sub SubFormCommandButton_Click()
       'Initiate Dialog Form
       DoCmd.OpenForm "myReasonFormName", , , , , acDialog
       ' if the Cancel button was selected in the Reason Form 
       ' then exit this subroutine.   
       If Me.Tag = "Cancel" then Exit Sub
       ' otherwise do whatever you want...
    End Sub
    In the Reason Form's Cancel button OnClick event:
    Private Sub ReasonFormCancelButton_Click()
       Form_mySubFormName.Tag = "Cancel"
    End Sub

    Self Taught In ALL Environments.....And It Shows!

  3. #3
    Join Date
    Mar 2005
    This worked!

    Thank you!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts