Results 1 to 9 of 9
  1. #1
    nicole.skeeters is offline Novice
    Windows Vista Access 2007
    Join Date
    Jul 2013
    Posts
    10

    Calculated Field on subform


    Hi, I'm back!

    I have searched through the forum trying to find the answer, but no one seems to be trying to get an answer from a calculated field like I am...On an inventory transactions list form, I want to do the "total cost" of the line item. In my text box control source, I have tried doing: =[Inventory List].[Quantity]*[Inventory Transactions].[Item Cost] only to receive a "#name?" on my form view. I also tried putting this expression in the query, thus making my control source: =[Inventory Transactions Extended]![Expr1] but with the same result. Is it not possible to pull from two different tables to make a calculated field? Or am I just doing this all wrong?

    Thanks,
    Nicole

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Try:
    =[Quantity]*[Item Cost]
    as the Control Source
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    nicole.skeeters is offline Novice
    Windows Vista Access 2007
    Join Date
    Jul 2013
    Posts
    10
    Well, while it did remove the "#name?" error, it just left a null value...I'm thinking because the item cost is stored in another table, "Inventory List," and not in the "Inventory Transactions List" where I'm trying to get the total cost to show.

  4. #4
    TG_W is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2010
    Location
    Manvel, TX
    Posts
    299
    Are you querying two different tables to produce the form? Without seeing the db structure, it sounds like you might want to add a field for the cost in the "Inventory Transactions List" so you can calculate. If you do not need to edit the data, you should be able to query the two tables together and get your cost.

  5. #5
    nicole.skeeters is offline Novice
    Windows Vista Access 2007
    Join Date
    Jul 2013
    Posts
    10
    Hmm. I added the field item cost to "Inventory Transaction List" and updated the control source - again no "#name?" error but no calculation either. I would not need to edit the data, no. Perhaps a better way to go about doing this is to just add total cost to reports instead of trying to make it populate on the order entry form?

  6. #6
    TG_W is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2010
    Location
    Manvel, TX
    Posts
    299
    Try checking this little deal I threw together. Probably does more than what you're looking for, but I can get the calculation you're looking for in VBA. I was just doing something similar.
    Attached Files Attached Files

  7. #7
    TG_W is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2010
    Location
    Manvel, TX
    Posts
    299
    Sorry, in .mdb format. It has code performing the calculations, and there is a relationship set in the database between the two tables.
    Attached Files Attached Files

  8. #8
    nicole.skeeters is offline Novice
    Windows Vista Access 2007
    Join Date
    Jul 2013
    Posts
    10
    Hey there, thank you for that! I'm getting an error: "Compile error: Method or data member not found." It is referencing the [Quantity] in the Private Sub. Any suggestions?

  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,772
    I tested TG's database and it works without error for me.

    However, why save the calculated extended price to table? This can be calculated whenever needed.

    The value you might want to save to transactions is the item cost if this cost could be changed in the future and don't want existing records to reflect the new cost. The alternative is a new item record in inventory and a field for setting records as active/inactive and excluding inactive records from combobox list.

    Options for retrieving the item cost from inventory list.

    1. join inventory table to transaction table, join type "Show all records from Transactions ...", bind textbox to field from inventory table, set it as Locked Yes, TabStop No

    2. include the price as another column in item combobox (which TG has done) and reference the column in a textbox

    3. DLookup() in textbox expression
    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.

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

Similar Threads

  1. Replies: 1
    Last Post: 04-21-2013, 03:20 PM
  2. Replies: 3
    Last Post: 02-13-2013, 10:15 AM
  3. Calculated Field
    By Richie27 in forum Programming
    Replies: 14
    Last Post: 06-05-2012, 03:16 AM
  4. Calculated Field
    By crcastilla in forum Access
    Replies: 2
    Last Post: 03-22-2012, 10:16 AM
  5. Calculated field
    By nashr1928 in forum Forms
    Replies: 3
    Last Post: 07-22-2010, 05:10 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