Passing a total from one form to another (1 Viewer)

moradisndat

Registered User.
Local time
Today, 01:46
Joined
Mar 27, 2015
Messages
14
I have "LossForm" to record loss of inventory items due to damage, theft, etc. It has "Loss Subform" for input of multiple items. The row has a calculated field "TotalLoss" (from qty * itemcost). The footer of subform has unbound text field =Sum(nz([TotalLoss])). This all works fine. The problem I have is that I need to pass the total to another form. I want to have a pop-up form to use some of the field values from the Loss form. I have been able to pass all of the field values except for the TotalLoss.

LossForm Close Event: "DoCmd.OpenForm "Journal", , , , acFormAdd, , Me.LossID & ";" & Me.LossDate

pop up form:
Set frmPrevious = Screen.ActiveForm
Me.TransactionID = frmPrevious.LossID
Me.EntryType = "Loss"
Me.Date = frmPrevious.LossDate
{ Me.Amount = frmPrevious.TotalLoss doesn't work }
DoCmd.Save
End Sub

I also tried to setup a global, class, and module variable but keep getting error message of undefined variable.

I apologize that my description of the problem may be difficult to understand , but if anyone can suggest the best way to do this or tell me what i am doing wrong, it would be greatly appreciated. I've spent so much time on this project (volunteered to do it without pay) and I am close to finishing but I think my brain is on strike. I've been referencing forums & tutorials online, "Getting results with MS Access 97" (yes i know it's 2015 and i'm using Access 2003 but that's how long it's been since i took the course), and 2 other massive books i got on ebay "Access 2000 VBA Handbook" & Osbourne's "Access 2000 Complete Handbook." The books are great and cover so much more than the class did. I've learned so much over the past few months but I just want to get it done so I can quit pulling my hair out. Please help... :banghead:
 

JHB

Have been here a while
Local time
Today, 10:46
Joined
Jun 17, 2012
Messages
7,732
If you are closing the form "LossForm" then you can't refer to a control on the form, and it seems you're are closing it, you can use the forms OpenArgs for transferring the value to the form you open, below is a link to the description + a sample how to use it!!
https://msdn.microsoft.com/en-us/library/office/ff836583.aspx
 
Last edited:

spikepl

Eledittingent Beliped
Local time
Today, 10:46
Joined
Nov 3, 2010
Messages
6,142
if your data is on the subform, then you need to refer to the proper name of the control:
forms!parentformname!subformname.form!controlname
 

Users who are viewing this thread

Top Bottom