Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Williams485 is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Feb 2013
    Posts
    42

    Calculated Field on form (beginner question)

    Hello Access Forum,



    I'm a newcomer to this forum and I'm a beginner with Access, so apologies for any questions that seem naive or ignorant!

    I have a calculated field that shows the sum of two other fields on the same form. I've got as far as making the expression work but it doesn't quite do what I want. I need the calculated field to update when any one of the reference fields are updated (i.e. currently it only updates once all the fields in the expression are updated).

    How to I change the form so that the calculated field updates based on current values (including any fields that contain no value)?

    Many thanks

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    This link should help: http://allenbrowne.com/casu-14.html

  3. #3
    qa12dx is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    india
    Posts
    112
    thanks RG. i didn't know about the calc field in access 2010. ess

    re thread q - like the link says, calculated field bad. be sure to read why. it will save u a LOT of heartburn
    in the form, put in an unbound textbox and just like u made the expression in the table, u'll do the same only u'll put a "equal to" sign.

    place a unbound textbox in form. if property box not visible, right click textbox and properties. under Data tab - Control Source put in ur expression, like below;

    =[qty]*[price]

    just remember basic math, BODMAS when u write these expressions. any terminology u r not fimiliar with google it

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    If you put the calculation in the query then you can bind a TextBox control to the AnswerField and the answer updates every time you change the input fields.

  5. #5
    Williams485 is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Feb 2013
    Posts
    42
    Hello and thanks for your replies.
    I've picked this up again having looked at the resource by Allen Browne and seem to be doing what it suggests. However, when I test my form and query I get "#NAME?" in the text box that contains the calculated field.
    The things I've done so far are:
    1. Enter expression into Query Design grid - the expression is exactly
    TtlLGDays: [FTSP LG Days] + [SA LG Days]
    2. On the form, select control source of the text box and open the Expression Builder dialogue. Select the new query - this enters
    [TtlLGDays]![TtlLGDays]
    into the expression box.

    When I then test the form, I get the error. From what I've read the error is usually an incorrect reference to the expression, field name, or something like this. However, I can't see any issue (perhaps I'm looking too hard!).

    Any suggestions welcome!

    Thanks

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    How about naming your calculated field something different from the name of the query?

  7. #7
    Williams485 is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Feb 2013
    Posts
    42
    Thanks, RuralGuy! Changed the name of the query so now reads:
    =[TtlLGDays]![qryLGDays]
    but the same error still occurs. Is there a tool in Access that will list all names (of fields, controls, queries, etc) so that I can glance through to ensure there's no more ambiguity?
    Is there anything else that could be causing the error?

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Is this value in the DropDown list of the ControlSource of that control?

  9. #9
    Williams485 is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Feb 2013
    Posts
    42
    It's the value shown in the property list but I didn't select it from the DropDown - I had to select it from the Expression Builder dialogue (...). It doesn't appear in the DropDown at all.

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    remove the RecordSource ofn the form and close the form after saving. Then open the form and set the RecordSource to the query again. Your field should be listed in the DropDown selection for the ControlSource of the TextBox and you should be able to select it. If not, then something is wrong.

  11. #11
    Williams485 is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Feb 2013
    Posts
    42
    I appreciate your continued help on this one... I've followed your instruction but the field doesn't appear on the list. It does, however, appear in the Record Source DropDown for the form itself? Does this give you any indication as to what is wrong?
    many thanks

  12. #12
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The RecordSource dropdown displays queries and tables, not fields in them. Does that suggest something?

  13. #13
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Did I loose you on that one?

  14. #14
    Williams485 is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Feb 2013
    Posts
    42
    Good morning, RuralGuy. It seems I hadn't actually posted my last reply of the day - but you did lose me a little.

    It tells me that my query is stored as a query (because it is showing in the Record Source drop down) but that my calculated field isn't, as it should be, in the Control Source drop down, which would suggest that there's something wrong with the field, not the query. This could be something wrong with the way I'm trying to set up my calculated field, or it could be something fundamentally wrong with my understanding of this situation!

    Any more clues??

  15. #15
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    How about posting the SQL for the query so we can see it?

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

Similar Threads

  1. Replies: 5
    Last Post: 01-21-2013, 01:09 PM
  2. Beginner - basic question
    By kevinnice in forum Programming
    Replies: 3
    Last Post: 03-08-2012, 11:31 AM
  3. Possible Access Question (total beginner)
    By SRobertson in forum Access
    Replies: 1
    Last Post: 01-12-2012, 06:01 PM
  4. Beginner-Importing excel table question
    By simmonsmtb in forum Import/Export Data
    Replies: 3
    Last Post: 03-07-2011, 11:55 AM
  5. Relational Structure - Beginner Question
    By CrazyFileMaker in forum Access
    Replies: 2
    Last Post: 01-02-2011, 11:28 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