Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Apr 2005
    Location
    Plovdiv
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Yes/No control (Access 2000)

    I want to perform a function called cancelorderonexit provided that customerid is Null ,the Yes/No control ChkStorehouse is set to True or the Yes/No field ChkWarehouse is set to True . Unfortunately the function below does not obey me, and the code is performed even though the ChkStorehouse is set to Yes
    If Not IsNull(Me![customerid]) Or IsNull(Me![ChkStorehouse]) Then
    CancelOrderOnExit
    DoCmd.CancelEvent
    End If

    What is wrong ?

  2. #2
    5 Star Lounger
    Join Date
    Apr 2003
    Location
    Hampshire, United Kingdom
    Posts
    602
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Yes/No control (Access 2000)

    IsNull(Me![ChkStorehouse]) should just be Me![ChkStorehouse] - so the full code should be:

    If Not IsNull(Me![customerid]) Or Me![ChkStorehouse] Then
    CancelOrderOnExit
    DoCmd.CancelEvent
    End If
    Waggers
    If at first you do succeed, you've probably missed something.

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

    Re: Yes/No control (Access 2000)

    I have one correction to make to your code. It is risky to write <code>Me![ChkStorehouse] Then</code> because you are relying on Access to properly coerce the value of a control into a boolean and this can cause unexpected behavior in your application (which can be horribly difficult to debug). Instead, use explicit comparisons with anything except a declared boolean: <code>Me![ChkStorehouse] = True Then</code>.
    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
  •