frodo9149 Level: Trainee
 Registered: 08-02-2005 Posts: 2
|
Re: Getting values from a called form
I have 2 forms, one that is a data form and the other an input form for users to enter margins or costs.
On the calling form I have a field called "End Cost" with the following code attached to the onexit event.
Private Sub End_Cost_Exit(Cancel As Integer)
If IsNull(Margin.Value) Or Margin.Value = 0 Then
DoCmd.OpenForm ("FrmMarginInput"), acNormal, acWindoNormal
End If
End Sub
The form FrmMarginInput has an unbound box with name nbrmarginvalue and another one called nbradjval.
The following code is attached to the OK button on this form
Private Sub okbutton_Click()
adjval = nbrAdjVal.Value
margvar = nbrMarginValue.Value
MsgBox (margvar) ' view margvar value
DoCmd.Close
MsgBox (margvar) ' view it again
DoCmd.GoToControl ("Margin") ' move to margin field on calling form
End Sub
I am using the msgbox proc to view the variables as I go through the code.
On this module the variables margvar and adjval are declared as Public.
When the margin input box closes, the program moves to the margin field on the calling form. On the onenter event on this field the following code is attached.
Private Sub Margin_Enter()
If Margin.Value = 0 Or IsNull(Margin.Value) Then
MsgBox (margvar), , "Margin Value"
If IsNull(margvar) Or margvar = 0 Then
MsgBox ("Cannot set Value"), , ("Warning")
Else
Margin.Value = margvar
End If
Else
MsgBox ("Value already entered"), , ("Warning")
End If
End Sub
The value from the input box should show up in the margin field but it does not. A null value shows instead.
I am perplexed, I hope this helps describe my problem.
Thank you.
|