reference to a field from another form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I has a form (main form) that open another unbound form to perform
calculalations. My problems are:

1) How do you transfer the information from the main form to the unbound
form.

2) How do you transfer the information in the unbound form (after
calculations) back to the main form

Many thanks
 
Here is one way.

1. Main form -> unbound form. Assuming main form will remai open when
opening the unbound form, do this on the unbound form:

Private Form_Open()
Combo1 = [Forms]![MainForm]![Combo1]
Text1 = [Forms]![MainForm]![Text1 ]
'etc, etc. for each control that must be populated
End Sub

2. Unbound form -> main form. Assuming unbound form will be closed when
returning to main form do this:

Use public variables. On your main form, add something like this to the
declarations section of the module.

Public DataTrans1 as Variant
Public DataTrans2 as Variant
Public TransFlag as Boolean

Now, before closing the unbound form, do this:

DataTrans1 = Combo1
DataTrans2 = Text1
'etc.etc.
TransFlag = True

Then, when returning to main form, do this:

Private Form_Activate()
If TransFlag Then
Combo1 = DataTrans1
Combo2 = DataTrans2
'etc.etc.
TransFlag = False
End Sub
 
Back
Top