Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Nov 2001
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cancel code (Access 2000)

    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?

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cancel code (Access 2000)

    Try this :
    <pre>If Me![OptTable] = 0 Then
    MsgBox "Please select the object. Otherwise action not possible"
    Exit Function
    End If
    </pre>

    Francois

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Cancel code (Access 2000)

    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.
    Charlotte

Posting Permissions

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