Page 1 of 3 123 LastLast
Results 1 to 15 of 33
  1. #1
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664

    Form Calculation is wrong!

    In performing the tutorial for Lesson 21, I was working on the College Park Auto Repair Form.




    I got the form as shown in the tutorial at about halfway through.

    However, I did not get anything for Tax Amount and Total Order. I believe that they

    are related. I cannot get the Total Order - it is calculated in the sum: if the Tax Amount is wrong so is Total Order.

    I got no errors when calculating the tax amount, but it certainly gave me useless information in the text box:

    #Name?

    .
    What did I do wrong? All the other calculations for that form are correct (except for Total Order).


    Any help appreciated. Thanks in advance.


    Respectfully,


    Lou_Reed


    The Lesson 21 tutorial is here:

    http://www.functionx.com/access/Lesson21.htm

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    To know what you might have done wrong, we need to see what you did. As orange suggests, provide copy of db for analysis.

    Where in that lesson does it describe these calculations?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I think that I see the problem. Let me try and explain. I will reproduce the instructions on this post (if I can).
    Code:
    1. Click the Order Summary tab
    2. Click the Tax Amount text box
    3. In the Property Sheet, click Control Source and change it as follows: =Nz([SubTotal1])+Nz([SubTotal2])+Nz([SubTotal3])+Nz([SubTotal4])+Nz([SubTotal5])
    4. On the form, click the Total Labor text box
    5. In the Data tab of the Property Sheet, change the expression in the Control Source as follows: =Nz([JobPrice1])+Nz([JobPrice2])+Nz([JobPrice3])+Nz([JobPrice4])+Nz([JobPrice5])
    6. On the form, click the Tax Amount text box
    7. In the Data tab of the Property Sheet, change the expression in the Control Source as follows: =CLng(CCur(Nz([txtTotalParts])+Nz([txtTotalLabor]))*CDbl(Nz([TaxRate]))*100)/100
    8. On the form, click the unbound Total Order text box
    9. In the Property Sheet, click Control Source and type: =CCur(Nz([txtTotalParts])) +CCur( Nz([txtTotalLabor])) + CCur(Nz([txtTaxAmount])
    10. Click Format and select Currency
    At point 3 and again at point 7. I calculate the Total tax amount. This seems to be calculated twice. Why?

    It seems to be wrong.


    Respectfully,


    Lou_Reed


  5. #5
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Here is my compacted database.


    College Park Auto Repair.accdb

    Okay, I think that I uploaded it correctly.

    Respectfully,

    Lou_Reed

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    Steps 3 and 7 are not the same calcs.

    Why are there 5 unit price and 5 quantity and 5 job price fields and therefore 5 sub total calcs? This is not non-normalized data structure. You should abandon this tutorial site. Or at least get an understanding of data normalization and recognize the difference that this site is demonstrating and its drawbacks.

    You are setting Caption property in table and using the same caption across multiple fields. I NEVER set display properties (such as Format, Caption, InputMask) in table.

    The controls on form are not given informative names. Which is supposed to be 'Tax Amount' textbox? There are no calculations in any of these boxes and none are bound to fields.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    I looked at the database structure from the site --- it is not normalized???? Very surprised!!!
    FunctionX has lots of good info -- I can't understand why the table is not normalized. I suppose it's possible they could be focusing on vba etc, but it's so obvious????

  8. #8
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Is that why the calcs on the form for College Park Auto Repair are wrong? The db is not normalized.

    Respectfully,

    Lou_Reed

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    No.

    Review my previous post again. Can't analyze your calcs because there aren't any.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    First you say that the database is wrong. I ask is that why I am getting errors. You say no - read earlier posts.

    Which is it. The calculation that are shown appear to be correct except for Total Tax Amount. Obviously, the are not five subtotals.

    I can make all of the unused values zero, but I am not sure it would work.

    Elaborate.

    Respectfully,


    Lou_Reed

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    The database is not normalized but calculations should still be possible as specified in the tutorial. Step 3 shows adding 5 sub totals.

    The db you posted does not have any calculations to be analyzed.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, the SubTotal4 and SubTotal5 are zero. As shown in another tab on the form. I think it is Parts Used.

    Every subtotal has a value, it is just that only subtotals 4 and 5 are 0.00. In an addition operation it obviously changes nothing.

    Under Jobs Performed there are only two entries out of a possible five. The first two have values and the last three do not. I assumed that they are

    zero and in the Parts Used tab. It appears not to show that. That is the first thing that I will check.

    I will see how this works out.

    Respectfully,


    Lou_Reed

  13. #13
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I think that I see the error. There is no equivalent Jobs Performed calculation like there is for Parts Used. They are essentially undefined (the last three). Hence adding them in will create the error.

    Okay, how did I get Total labor and Total Parts right?

    I think that I see the error. I am not sure if it will solve all of the
    error seen, but I will try and see.


    Respectfully,

    Lou_Reed

  14. #14
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    In the control source one normally inputs formulas that are like this:

    =Nz([JobPrice1])+Nz([JobPrice2])+Nz([JobPrice3])+Nz([JobPrice4])+Nz([JobPrice5]

    However , that is not very descriptive. Is it possible to expand that formula like this:

    Nz([txtTotalLabor])=Nz([JobPrice1])+Nz([JobPrice2])+Nz([JobPrice3])+Nz([JobPrice4])+Nz([JobPrice5]


    and then only use the left hand side in any future calculations? That value, Nz([txtTotalLabor]), seems a lot more descriptive and, of course, it is far easier to write that
    than

    =Nz([JobPrice1])+Nz([JobPrice2])+Nz([JobPrice3])+Nz([JobPrice4])+Nz([JobPrice5]

    if it is ever used in the future.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou_Reed

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    Yes, can reference txtTotalLabor textbox in other expressions on the form.

    However, saving this value into table is not advised. Do this calc when needed.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Page 1 of 3 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Form opens in wrong view
    By gar in forum Forms
    Replies: 3
    Last Post: 07-10-2015, 12:47 AM
  2. Calucation of Months between 2 records...
    By tanyalee123 in forum Queries
    Replies: 5
    Last Post: 05-09-2014, 02:45 PM
  3. Form dislays wrong record.
    By Quercus in forum Forms
    Replies: 9
    Last Post: 02-15-2014, 07:19 PM
  4. Can not refresh a form - what am I doing wrong?
    By RedGoneWILD in forum Forms
    Replies: 9
    Last Post: 06-26-2012, 04:53 PM
  5. Form with Subreport Displaying Wrong
    By claysea in forum Forms
    Replies: 3
    Last Post: 02-14-2012, 03:25 PM

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