
Two Questions - Making a userform active / Accessing a userform via a variable
Simon
There are two ways to crack the first part of your problem:
The first is to use global variables (variables declared as Public outside
of the forms) to pass data between your forms.
The second is to refer to the controls that you want the values from. As an
example I have created two forms. The first form is called "frmMain", it
has a TextBox control called "txtMain" and and CommandButton control called
"btnShowSubForm". The forms code follows:
Private Sub btnShowSubForm_Click()
frmSub.Show
frmMain.Move frmMain.Left
txtMain.Text = frmSub.txtSub.Text
Unload frmSub
Application.Activate
End Sub
The second form is called "frmSub" it has a TextBox control called
"txtSub" and and CommandButton control called "btnOk". The code for this
form follows:
Private Sub btnOK_Click()
Me.Hide
End Sub
To test this start "frmMain" not "frmSub". If you click on "frmMains"
button it will display "frmSub". Anything you enter in frmSub's TextBox
will be displayed in frmMain's TextBox when you click on frmSub button.
You must use Me.Hide and not Unload Me in the subform otherwise you will
always get null values!
The Application.Activate should bring your initial form to the front.
I hope this helps + Cheers - Peter
Quote:
> Hello, I hope someone can assist me with the following problems:
> 1 - I have a common form (frmOutlookAddress) that is called by a
> number of other forms (frmLetter, frmComp, frmFax etc). I want to be
> able to pass information back to a textbox in the calling form. All
> the calling forms have texboxes with the same name, so I want to do
> something like:-
> myCallingForm.txtAdd1 = frmOutlookAddress.txtAdd1
> The variable myCallingForm would hold the name of the form that calls
> frmOutlookAddress. I have tried various ways of doing this, but cannot
> seem to get it to work.
> 2 - I have a form (frmOutlookAddress) that has a button to change the
> Outlook folder that the user wishes to query (using Set oFolder =
> oNspc.PickFolder.) . This brings up an Outlook window to enable them
> to select the required folder, however once they have done this, the
> form is no longer the active window. How do I specify that I want
> frmOutlookAddress to be 'on top' and active?
> I would be very grateful if someone out there could point me in the
> right direction.
> TIA
> Simon