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

Cancelling code in current event

Status
Not open for further replies.

SimonPGreen

IS-IT--Management
Mar 8, 2004
116
GB
Hi,

I have some code using the Dmax function in the current event of a form. I need to stop this code from running based on a user response on form load

Code:
If Me.NewRecord And Me.OpenArgs <> "" Then
        Select Case msgbox("No Packages found. Create new?", vbYesNo)
        Case Is = vbYes
            Me!FKContractRef = Me.OpenArgs
        Case Is = vbNo
            DoCmd.Close
            Exit Sub
        Case Else
            DoCmd.Close
            Exit Sub
        End Select
    End If
If the user clicks no the form still seems to go through its event sequence before the closing events - how can I stop this?

Appreciate any help.

Regards,

Simon
 
What is the line you are using to open this form?

PS Why not:
Code:
If Me.NewRecord And Me.OpenArgs <> "" Then
        If msgbox("No Packages found. Create new?", vbYesNo) = vbYes
            Me!FKContractRef = Me.OpenArgs
        Else
            DoCmd.Close
            Exit Sub
        End If
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top