Not sure if this is the right place to post this or not - if it's in the wrong place please let me know and I'll shift it!
Basic problem...
In a forms class module some calculations are made, the result of one of which is then passed to a publically declared variable in the modules header.
When a button on the form is pressed, a report is opened. The report is made up of various fields, some taken from the form the button is on, some from a table, but most importantly, One is the variable publically declared in the form module.
Problem is - it cant access it - it just pops up an input box asking for the variable!
Below is the basic bits of code...
In the form...
I then have a report "rptrefund" with a field in it that is calculated using the public variable IPTcalc....
only that's where it goes pear shaped
it pops up the box asking me to input IPTcalc instead!!
I've got similar problems in a couple of places - this is the simplest one so thought I'd start there. Am I totally misunderstanding how/what public variables are for, or just implementing it wrong?
I've actually found a way around it for the above example by adding a unbound field named "IPTamnt" into the form, assigning the figure that would have been IPTcalc to the field and then changing the code in the report to read
but that seems somewhat messy to me and is not really viable in other areas where I need to access variables from all over the place!
Basic problem...
In a forms class module some calculations are made, the result of one of which is then passed to a publically declared variable in the modules header.
When a button on the form is pressed, a report is opened. The report is made up of various fields, some taken from the form the button is on, some from a table, but most importantly, One is the variable publically declared in the form module.
Problem is - it cant access it - it just pops up an input box asking for the variable!
Below is the basic bits of code...
In the form...
Code:
Option Compare Database
Option Explicit
Public IPTcalc as double
----------------------------------
Private Sub CalcRefund_Click()
Dim response
If Me![NotRenew] = False Then
Me![PeriodCover] = Me![Cancelled] - Me![OnRiskFrom]
Me![PeriodPremium] = ((Me![Premium] / 365) * Me![PeriodCover]) * -1
IPTcalc = Me![PeriodPremium] * Me![IPT]
DoCmd.OpenReport "rptrefund", acNormal
Else
Response = MsgBox("This policy was cancelled at renewal" _
& Chr(10) & "No Refund is Due", vbCritical, "STOP!")
End If
End Sub
I then have a report "rptrefund" with a field in it that is calculated using the public variable IPTcalc....
Code:
me![refundexcess] = me![baseprem] - IPTcalc
only that's where it goes pear shaped
I've got similar problems in a couple of places - this is the simplest one so thought I'd start there. Am I totally misunderstanding how/what public variables are for, or just implementing it wrong?
I've actually found a way around it for the above example by adding a unbound field named "IPTamnt" into the form, assigning the figure that would have been IPTcalc to the field and then changing the code in the report to read
Code:
me![refundexcess] = me![baseprem] - [forms]![frmrefund]![IPTamnt]
but that seems somewhat messy to me and is not really viable in other areas where I need to access variables from all over the place!