Results 1 to 4 of 4
  1. #1
    juggernauts is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2014
    Posts
    3

    Need help on how to pass calculated field from a subform to another subform

    Hi,



    I need your expert advice on how to get calculated result on a subform of Form A to subform of Form B

    For example, below is my calculated field in Form [frmStockSearch]
    =Nz(DSum("[Qty]","tblPurchaseOrderDetails","[SentTo] = 'Store' AND [ItemCode] = " & [Forms]![frmStockSearch]![ID]),0)
    -Nz(DSum("[Qty]","tblOrderDetails","[SentFrom] = 'Store' AND [ItemCode] = " & [Forms]![frmStockSearch]![ID]),0)

    I want to use the same calculation result in Form [frmStockSearchClient]. I know I can copy the same code by changing [frmStockSearch] to [frmStockSearchClient], but it is tedious as I have many calculated fields and many forms.

    Thank you for your help. I greatly appreciate that.

    Juggie

    Also posted at http://www.pcreview.co.uk/forums/nee...-t4063584.html
    Last edited by June7; 04-01-2014 at 04:29 AM.

  2. #2
    fredz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Posts
    19
    I have used a couple different methods.
    1. Dim a public variable in a module. Then you can use that value most anywhere.

    2a. Create a textbox on the parent form.
    2b. It can be hidden if you don't want the users to see it. Otherwise, it should be locked so users don't try to change it.
    2c. Whenever the value gets calculated in the subform (on current event, after update event, etc) change the textbox value (ie: Me.Parent.txtboxname = calculatedvalue).
    2d. Use the textbox value in the 2nd subform.

    Hope that helps,
    Fred

  3. #3
    juggernauts is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2014
    Posts
    3
    Hi Fred,

    Thank you for your advice. I have managed to get to calculated value from a subform of form A to another subform on form B.
    However, the problem is I have to open Form A in order to see the calculated value in subform of Form B. Is there solution?

    Moreover, how to put this calculated value into a query. So far I have put the following expression into field :
    Nz(DSum("Qty","tblPurchaseOrderDetails","[SentTo] = 'Store' AND [ItemCode] =" & [tblItem].[ID]),0
    -Nz(DSum("Qty","tblOrderDetails","[SentFrom] = 'Store' AND [ItemCode] =" & [tblItem].[ID]),0)

    This expression works, but it takes extremely long time to finish the query.

    Thank you for your great help.

    Juggie

  4. #4
    fredz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Posts
    19
    It appears you're attempting to get the net value of purchases by a store (SentTo - SentFrom) for an item.
    So, possibly create multiple queries...

    Query #1 - A total by store & item of items being Sent
    Query #2 - A total by store & item of items being Received
    Query #3 - A join of these two queries

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

Similar Threads

  1. Put calculated field on subform
    By TioAdjie in forum Forms
    Replies: 2
    Last Post: 02-23-2014, 09:43 PM
  2. Calculated Field on subform
    By nicole.skeeters in forum Forms
    Replies: 8
    Last Post: 07-23-2013, 05:55 PM
  3. Pass Value from a form to a subform
    By b_best in forum Forms
    Replies: 1
    Last Post: 03-30-2012, 08:56 AM
  4. Pass Subform filter to subform in report
    By camftm in forum Programming
    Replies: 16
    Last Post: 07-19-2011, 07:12 AM
  5. how to pass pk to subform
    By ahmed.gomaa in forum Forms
    Replies: 9
    Last Post: 03-21-2010, 10:03 AM

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