Hello,
This is my first question on this forum. I got good help from time to time by reviewing others threads and issues.
I have problem to manage the values from two different forms.
On first form we calculated results from two textboxes and store into a public variable. On this form there is a button which close the current active form and open second form . I need to show the result of first form on the second form.
On codes available on form ‘FirstForm’
Option Compare Database
Public results As Integer
Private Sub txtFirst_AfterUpdate()
Me.lblResult.Caption = Val(Me.txtFirst.Value) + IIf(Me.txtSecond = Null, 0, Val(Me.txtSecond.Value))
results = Me.lblResult.Caption
End Sub
Private Sub txtSecond_AfterUpdate()
Me.lblResult.Caption = Val(Me.txtFirst.Value) + Val(Me.txtSecond.Value)
results = Me.lblResult.Caption
End Sub
Private Sub cmdNext_Click()
DoCmd.Close , "FirstForm"
DoCmd.OpenForm "Second"
End Sub
On second form OnLoad event is;
Option Compare Database
Private Sub Form_Load()
Me.lblFromFirstForm.Caption = results
End Sub
If I use Me.lblFromFirstForm.Caption = Forms!FirstForm.lblResult.Caption on second form I get the value from the first form. But I wanted to manage it through variables. Please advice.
Thanks
Ismail
This is my first question on this forum. I got good help from time to time by reviewing others threads and issues.
I have problem to manage the values from two different forms.
On first form we calculated results from two textboxes and store into a public variable. On this form there is a button which close the current active form and open second form . I need to show the result of first form on the second form.
On codes available on form ‘FirstForm’
Option Compare Database
Public results As Integer
Private Sub txtFirst_AfterUpdate()
Me.lblResult.Caption = Val(Me.txtFirst.Value) + IIf(Me.txtSecond = Null, 0, Val(Me.txtSecond.Value))
results = Me.lblResult.Caption
End Sub
Private Sub txtSecond_AfterUpdate()
Me.lblResult.Caption = Val(Me.txtFirst.Value) + Val(Me.txtSecond.Value)
results = Me.lblResult.Caption
End Sub
Private Sub cmdNext_Click()
DoCmd.Close , "FirstForm"
DoCmd.OpenForm "Second"
End Sub
On second form OnLoad event is;
Option Compare Database
Private Sub Form_Load()
Me.lblFromFirstForm.Caption = results
End Sub
If I use Me.lblFromFirstForm.Caption = Forms!FirstForm.lblResult.Caption on second form I get the value from the first form. But I wanted to manage it through variables. Please advice.
Thanks
Ismail