Results 1 to 13 of 13
  1. #1
    Rwatson is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    7

    Access app, Query problem

    I am having a problem writing a query in the Access app. I'm writing an expression where i am multiplying a field by a number. Then i take that new field and multiply it by another number in the next field.


    Example.



    Weight(g): [Volume]*5

    Weight(oz): [Weight(g)]*5


    However, when i finish the second field and try to save the query, it comes up with an error (invalid field name). As best i can figure out, it doesn't want there to be two fields with the same name.
    Everything else is working great, just this one thing is standing in my way.

    Any ideas?

    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Certainly can't have two fields with same name but I don't see two fields with same name.

    Try not using special characters/punctuation (underscore is exception) in names.

    Or since it is really a simple, short expression, just use the Volume field again:

    Weight_oz: [Volume]*25
    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.

  3. #3
    Rwatson is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    7
    [QUOTE=June7;259132]Certainly can't have two fields with same name but I don't see two fields with same name.


    Example a

    Weight(g): [Volume]*5
    Here i am making a new field that is calculated by taking the volume and multiplying it by 5.

    Example b

    Weight(oz): [Weight(g)]*5
    Here i want to use the value i found for the weight in grams and multiply it by 5. Access keeps telling me that weight in grams has already shown up once (example part a) and it wont except it in this expression.


    I other words you cant use the same field in multiple expressions.
    That is the problem i am trying to work around.

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    I think it may be your use of brackets () that it doesn't like - it is interpreting them as array subscripts. As June7 suggested, try Weight_g and Weight_oz as field names.

    Additional info: I'm using Access 2010, and I cannot replicate the error. The brackets are OK, I can use the same fields more than once, and I can use a previous field name with brackets in an expression - query SQL below:

    SELECT CmptcyInst_ID, Stat_ID, Stat_LVL, Stat_SEQ, [stat_id]/2 AS [Text(a)], [text(a)]*2 AS [text(b)], [text(a)]*1 AS [text(c)]
    FROM Competency_Statement

    So maybe it's something "new" in A2013.
    Last edited by John_G; 01-07-2015 at 11:17 AM. Reason: Additional comments

  5. #5
    Rwatson is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    7
    I already tried that. Just to make sure i named a field "g" (without the quotes obviously) and it still rejected it. Everything is fine until the field name shows up in an expression after it has been set as the field title.

    Should i take some screen shots or something?

    Thanks

  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,770
    Attach whatever you think will help: screen shot, the SQL statement, the database.

    I suggested using the native Volume field in the expression so don't have to use the constructed field.

    However, really should be able to use the constructed field. So this is odd. Odd often means corruption.
    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
    Rwatson is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    7
    Here is a screen shot. Remember this is the Access web app not the desktop version. I replicated this query in the desktop access and it worked fine.

    Click image for larger version. 

Name:	PartWeightG.jpg 
Views:	5 
Size:	193.5 KB 
ID:	19252

  8. #8
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    first, as others have mentioned, take the () marks OUT of your field names.

    part volume (in3)

    change this field name to something like part_volume_in3

    Second depending on whether or not you are aggregating your current formulas may or may not work. to be more thorough you should have something like

    PartWeightG: [Part_Volume_in3] * 5
    PartWeightL: ([Part_Volume_in3] * 5)*5

  9. #9
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    From the screenshot, it's ambiguous as to what is causing the error because you use the field name PartWeightG twice. Conceivably it's the use in the first column it doesn't like (though I can't imagine why - Capital letters maybe???))

    Change the name in column 1 (only) to PartWeightX for example, and see what the error message is.

  10. #10
    Rwatson is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    7
    If i'm understanding you correctly you are saying to add the entire equation the number is built on before adding another operation to the expression.
    If at all possible i would really like to avoid this because i have quite a few more fields that need to be generated from previous fields. It all builds on itself and the equations would get really long.


  11. #11
    Rwatson is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    7
    It is still coming up as the same thing but now i don't know why.

    Click image for larger version. 

Name:	PartWeightX.jpg 
Views:	4 
Size:	187.1 KB 
ID:	19254

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    What is [part volume (in3)]? Is that a field in table?

    You show compound joins. You are not using the values of PK ID fields as foreign key? Why? If you are not using the ID fields then why have them designated as PK? Should have composite PK.

    Expand the table boxes so all fields can be seen.
    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.

  13. #13
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    first, answer a basic question.

    Do you actually have a field named

    PART VOLUME (in3)

    On one of your tables?
    Secondly why not add a field from one of your tables, it may be crashing because you are not showing any data, just formulas, try adding your field that you're trying to peform this calculation on (the actual field PART VOLUME (in3))

    Lastly... how about you upload a sample database with some garbage data in it to illustrate the question. Just copy your database, take out any private information but leave enough fake data in there to duplicate the problem, then zip it up and upload it through the GO ADVANCED function on this forum.

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

Similar Threads

  1. Query problem in Access 2010
    By Lynn Cohen in forum Access
    Replies: 2
    Last Post: 09-17-2014, 11:41 AM
  2. Access/Append Query/Problem
    By Reety in forum Access
    Replies: 5
    Last Post: 03-11-2014, 12:05 PM
  3. MailMerge Problem from Access Query
    By txacoli in forum Access
    Replies: 12
    Last Post: 04-12-2012, 06:08 AM
  4. access 2007 query problem
    By jassie in forum Queries
    Replies: 1
    Last Post: 03-14-2012, 04:21 PM
  5. problem with IF THEN statement in access 2003 query
    By sfgiantsdude in forum Access
    Replies: 4
    Last Post: 01-05-2012, 04:23 PM

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