Results 1 to 6 of 6
  1. #1
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2002
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    If Statement, Need to change value to 0

    I need the value of TaxA to be 0 if TaxStatus (which is a combo with 2 values of Taxable and NonTaxable) has the value of NonTaxable

    TaxA has a default value of 0.0825

    Here is my code, which is NOT working. It is running on the OnCurrent Event of the form.


    If [TaxStatus] = "NonTaxable" Then
    TaxA.Value = 0#
    End If

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Do you get an error message?
    What happens?
    Have you tried putting a Break Point in the Code to see the values as you step through the code? I would put a Break Point on the first line of the If statement and then see what the value of/in TaxStatus is. Is TaxStatus a text box on the form?

  3. #3
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2002
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Here is the error message:

    Run-time error 2447


    There is an invalid use of the . (dot) or ! operator or invalid parenthesis

  4. #4
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    I just tried every which way to make your code error out in my test database but I was not able to.
    I put the code behind a command button - AND in the OnCurrent Event of the Form . . . it runs just fine.
    I tried reading a value from a TextBox AND from a Combo Box . . . no problem.

    Any chance that you can post a copy of your DB here?
    I'm using Access 2010 - and though I have never used 2002, I have used Access starting in 1995 all the way through now and I'm not sure what the problem might be. If I was able to look at the DB myself, I might be able to figure it out.

    1. Did you try putting a break point in the code to debug? Are you familiar with how to do that?
    2. What is TaxA on your Form?

  5. #5
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2002
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    Here is the subform

    You did not miss anything with 2002 I can assure you. I tried putting a break in the code, not sure if I did it right, never done that before.

    TaxA is used to set the default tax rate, i.e. 0.0825 It actually refers to a subcontrol named Tax and gets its value from there. It is an unbound control.
    Attached Files Attached Files
    Last edited by burrina; 11-01-2012 at 04:03 PM. Reason: attached demo db

  6. #6
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Your TaxStatus control . . . and the section in which it was housed . . . were both set to Visible = N.
    As a result, when I tried to set the focus to TaxStatus, Access was not able to set the focus to that control.
    Once I made both the section and the control visible, the code worked fine.

    I'm not sure why your Form is set up the way it is, but you will have to make sure that at the point in your code where you are referring to the TaxStatus control, Access can actually get TO the control.

    Let me know if you have any other questions.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. if statement in sql statement, query builder
    By 54.69.6d.20 in forum Access
    Replies: 4
    Last Post: 09-11-2012, 07:38 AM
  2. Replies: 3
    Last Post: 07-20-2012, 11:41 AM
  3. Replies: 7
    Last Post: 08-17-2011, 01:49 PM
  4. IIF statement
    By LilMissAttack in forum Queries
    Replies: 2
    Last Post: 08-05-2011, 08:49 AM
  5. IIf Statement
    By dref in forum Forms
    Replies: 2
    Last Post: 07-16-2010, 02:46 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums