Results 1 to 10 of 10
  1. #1
    nashr1928 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Apr 2010
    Posts
    146

    Calculated field


    I have a form thay I put a calculation in a field called percent. This is what I have. =Sum([end milage]-[start milage]/[end milage]). This is to calculate the difference between the 2 columns as a percent. The problem is that nothing happens. The field stays blanc. Any idea's ?

  2. #2
    Join Date
    May 2010
    Posts
    339
    Hi nashr1928,

    I just tried it and it works fine. Here is what I did. On my form I used your two fields end milage and start milage. In design view I placed a UNBOUND textbox with this in the control source in the forms/footer.

    Code:
    =Sum([end milage]-[start milage]/[end milage])
    The trick is not to store the results in your table. Also the spaces in your field names will be trouble later on.


    Richard

  3. #3
    nashr1928 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Apr 2010
    Posts
    146

    Calculated Field Cont.

    Hello and thank you for trying this out. Thanks for the heads up about spaces although I have alot of work to do now changing names of everything. I have taken this calc to another level to achieve the result that I wanted but do not know how to express it the correct way to make it work. This is what Im trying to do: end milage - start milage / end milage * 100. This looks like 144777 - 140953 = 3824 / 144777= .026413 * 100 = 2.6413%. This is how I expressed it =Sum([end milage]-[start milage]/[end milage]*100). This is what I get as a result 14467964.1%

  4. #4
    nashr1928 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Apr 2010
    Posts
    146
    Have tried what you suggested but for some reason the arithmatic is giving the incorrect answer. Not sure whats going on.

  5. #5
    nashr1928 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Apr 2010
    Posts
    146
    I finally found the answer that made it all work with the correct mathmatical answer. This is what I had inserted before: =[End Milage]-[Start Milage]/[End Milage]*100. This always gave me the results from the [End milage]. This is what I have inserted now and gives me a true percentage answer. =([End Milage]-[Start Milage])/[End Milage]*100

  6. #6
    Join Date
    May 2010
    Posts
    339
    Ok I didn't think that looked right. Have a look a my sample query.
    Let me know if that is the correct results.

  7. #7
    nashr1928 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Apr 2010
    Posts
    146

    Calculated cont...

    Yes I looked and its the same as the way I did it. The same results.

  8. #8
    nashr1928 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Apr 2010
    Posts
    146
    I looked at your query and that may be the way. I may add that to an additional query that already exists. Thanks for helping on this. I do have a question though about what you said about spaces in names. What exactly happens when trouble statrs?

  9. #9
    Join Date
    May 2010
    Posts
    339

    Calculated field

    Here is a couple of reasons:

    John W. Vinson [MVP]
    You can use spaces in names... if you a) ALWAYS use [square brackets] in SQL,
    VBA, and other field references; and b) accept that this will give you (or
    some poor frustrated successor) major headaches if you ever need to upsize to
    SQL/Server or another database engine that isn't so friendly.
    So extra brackets around your field names. But consider this every field name has a Label, that is what the user views NOT the true field name. Example would be a field name, StartTime is displayed as Start Time using its label.
    Also remember don't store the caculations in your table.

    HTH
    Richard

  10. #10
    nashr1928 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Apr 2010
    Posts
    146

    Calc fields cont.

    Thanks so much for your advice. I totallt understand about what your saying about field names. Thanks again and have a nice rest of the week end.

    Rick

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

Similar Threads

  1. Calculated field
    By nashr1928 in forum Forms
    Replies: 3
    Last Post: 07-22-2010, 05:10 AM
  2. Sorting a Report by a Calculated field
    By mulefeathers in forum Reports
    Replies: 1
    Last Post: 05-22-2010, 08:21 PM
  3. union query with a calculated field
    By grad2009 in forum Queries
    Replies: 9
    Last Post: 03-31-2010, 04:50 PM
  4. Formatting a Calculated Field
    By e_lady333 in forum Queries
    Replies: 0
    Last Post: 03-17-2010, 06:11 PM
  5. Calculated Field in continuous form
    By doobybug in forum Forms
    Replies: 2
    Last Post: 11-15-2009, 08:54 AM

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