Results 1 to 13 of 13
  1. #1
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Using 'yes/no' with forumulas (2000)

    Back again. I'm trying to code a form so that it will look to see if the Account is Tax Exempt or not and the apply tax accordingly. Whenever I use If/than statements with yes/no controls I have no luck. This is what I wrote.

    If me.TaxeExpemptStatus.value = "No" then
    [SalesTax] = [LaborCost] * .06
    Else: [SalesTax] = 0
    End if

    And, I've tried:

    If me.TaxeExpemptStatus.value = "No" then
    [SalesTax] = [LaborCost] * .06
    Else if me.TaxExepmtStatus.value = "Yes" then
    [SalesTax] = 0
    End if


    I've tried taking out the word "value" as well as putting in -1 for no and 1 for yes and still the code doesn't run.

    Leesha

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

    Re: Using 'yes/no' with forumulas (2000)

    Yes and No are constants, not strings. Take the quotes out from around them and you should be OK.

    If me.TaxeExpemptStatus.value = No then
    Charlotte

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Using 'yes/no' with forumulas (2000)

    In the first place, check for spelling errors again. In your post, you have TaxEx<big>P</big>emptStatus and TaxExe<big>P</big>mptStatus.

    In the second place, a Yes/No field has values True and False (without quotes)

    Assuming that the control is named TaxExemptStatus, the code could be

    If Me.TaxExemptStatus = True Then
    Me.SalesTax = 0
    Else
    Me.SalesTax = Me.LaborCost * .06
    End If

  4. #4
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Using 'yes/no' with forumulas (2000)

    Hi,

    There weren't any spelling errors in the code. I just typed in the various things I'd tried vs cut and paste since I'd tried various versions. I'm pretty sure its related to the quotes as Charolotte just pointed out.

    Thanks to both of you!
    Leesha

  5. #5
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Using 'yes/no' with forumulas (2000)

    Also Hans solution could be changed from:
    If Me.TaxExemptStatus = True Then

    to:
    If Me.TaxExemptStatus Then

    This assumes that you are indeed testing for True.

  6. #6
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Using 'yes/no' with forumulas (2000)

    Whoa, I have noted that one. Why on earth don't they fix it, especially if they allow it?

  7. #7
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Using 'yes/no' with forumulas (2000)

    I kept the yes/no and took away the quotes and that corrected the issue. Another learning experience.

    Thanks to all three of you!

    Leesha

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

    Re: Using 'yes/no' with forumulas (2000)

    That isn't a good idea, Pat. It is recommended against in knowledgebase articles, and I have seen it cause problems.

    A checkbox control needs to be evaulated either with the full expression Me.Checkbox=True or by forcing an evaulation by enclosing the reference in parens (Me.Checkbox). Not doing so is one of the many causes of databases closing but the Access process remaining open.,
    Charlotte

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

    Re: Using 'yes/no' with forumulas (2000)

    You'd have to ask Microsoft that question. I suspect it's more a VBA issue than a pure Access issue though, since there seems to be a memory leakage associated with that kind of code statement.
    Charlotte

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Using 'yes/no' with forumulas (2000)

    The use of yes and no doesn't raise an error message only because you don't have Option Explicit in your modules; you should replace them by True and False.

  11. #11
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Using 'yes/no' with forumulas (2000)

    Morning Hans!

    Missed ya yesterday, but Pat and Charlotte took care of me.

    I don't have a problem changing the yes/no to true/false but am just wondering why yes/no is even given as an option when setting up a table. Its my need to understand kicking in again!

    Leesha

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Using 'yes/no' with forumulas (2000)

    In a table and in a query, you can use Yes/No or True/False as you please. This is the interface for "everyone", it should be as user-friendly as possible.
    In Visual Basic, you must use True/False. Code windows are just for programmers; the end user should never see them.

  13. #13
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Using 'yes/no' with forumulas (2000)

    OK, that makes sense to me. Thanks for the explanation!!

    Alicia

Posting Permissions

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