• Cancel code (Access 2000)

    Author
    Topic
    #366645

    I have a function performing different tasks depending on the option the
    customer has chosen. :

    If Me![OptTable] = 0 Then
    MsgBox “Please select the object. Otherwise action not possible”
    cancel = true

    I do not want to use the Else in the If case, and i want to stop the code from executing the command and return to the original state.In other words, to happen nothing in case the customer has not chosen an option I am trying with the cancel event, but obvisoulsy i canot apply cancel in this case.
    How can i achieve it?

    Viewing 1 reply thread
    Author
    Replies
    • #569201

      Try this :

      If Me![OptTable] = 0 Then
      MsgBox "Please select the object. Otherwise action not possible"
      Exit Function
      End If
      
    • #569279

      An alternative that I prefer is to set a flag in the conditional and then test for that flag as you proceed. So if you set a flag like blnContinue = False and then test for blnContinue before you do anything else in your code, it will ultimately fall through to whatever exit steps you take in that function. Simple doing an Exit Function bypasses any niceties like turning warnings back on or destroying object variables.

    Viewing 1 reply thread
    Reply To: Cancel code (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: