Results 1 to 9 of 9
  1. #1
    Lea is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    6

    Expression Difficulties


    Help...

    I can not get an expression to work.

    I would like to multiply some fields and then total the results. This is just one expression that I tried...

    =Sum(([# of Containers 1-1:]*[Gal ea 1-1:])+([# of Containers 1-2:]*[Gal ea 1-2:]))

    The error message I get is:

    "The database engine does not recognise either the field '# of Containers 1-1:', or the default value in the table 'Table 1'."

    Thinking there is some little mistype on my part, I copy/pasted the field name right from the properties but I still got the same error.

    In excel I would write this...

    =((G2*I2)+(J2*L2))

    I am getting frustrated. I have to use access but my heart belongs to excel for writing formulas. Can anyone tell me what I am doing wrong?

    Any help is greatly appreciated.

  2. #2
    SteveH2508 is offline Competent Performer
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Chelsea, London, England
    Posts
    117
    Where are you putting this expression?

    Do all of your fields names have colons after them and why?

    Another 'painsaver' if you can implement it - it is not good practice to use spaces or punctuation marks in field names. It makes expressions much more difficult to write (as I suspect might be the case here!)

  3. #3
    Lea is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    6
    Hello SteveH2508,

    Thanks for replying.

    I put the expression in the Default Value of the Field Properties for a field titled TotalGalForLot1.

    I changed the field names and used the expression below. I am still getting the same error message.

    =Sum(([NumberOfContainers11]*[GalEa11])+([NumberOfContainers12]*[GalEa12]))

    Lea

  4. #4
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    you can not reference to any other fields for a default value of a field. Generally, people don't save a calculation in a table. they use query to get the calculation result when they need.

  5. #5
    Lea is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    6
    weekend00,

    I will have to hit the help section and make a query to calculate. At least I can stop banging my head on what I was trying. Thank you for the help. I appreciate it.

    Lea

  6. #6
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    u r welcome. hope you get it soon.

  7. #7
    SteveH2508 is offline Competent Performer
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Chelsea, London, England
    Posts
    117
    Another point - you should generally not store calculated fieds in tables - it breaks the rules of normalisation. You should calculate the value when you need it at run-time using a query or expression in a form/report.

  8. #8
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You should also not use spaces or special characters in object names. (see http://mvps.org/access/tencommandments.htm)

    And seeing
    "[# of Containers 1-1:]" and "[# of Containers 1-2:]" indicates to me that you do not have a normalized table structure. You should stop and review your structure.......




  9. #9
    Lea is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    6
    ssanfu,
    Thank you for the tip.
    Lea

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

Similar Threads

  1. Expression Help
    By Hammer in forum Queries
    Replies: 2
    Last Post: 01-14-2011, 10:30 AM
  2. Looking for help with an expression
    By CoachBarker in forum Queries
    Replies: 3
    Last Post: 11-25-2010, 05:17 AM
  3. Expression value
    By KWarzala in forum Reports
    Replies: 0
    Last Post: 06-15-2010, 12:35 PM
  4. Expression trouble
    By ROB in forum Access
    Replies: 2
    Last Post: 06-08-2010, 09:36 AM
  5. Help With an expression
    By kylem4711 in forum Queries
    Replies: 2
    Last Post: 04-23-2009, 01:57 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