Two Questions - Making a userform active / Accessing a userform via a variable 
Author Message
 Two Questions - Making a userform active / Accessing a userform via a variable

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



Fri, 26 Aug 2005 19:36:46 GMT  
 Two Questions - Making a userform active / Accessing a userform via a variable
Quote:
> 1 - ... etc

2 Userforms, and below sequence exchanges the values
from TextBox1 on the active userform to the other TextBox1
on the other userform

    Dim f As UserForm2
    Load f
    f.TextBox1 = Me.TextBox1
    f.Show

Quote:
> 2 - form is no longer the active window. How do I specify that I want
> frmOutlookAddress to be 'on top' and active?

If you keep frmOutlookAddress loaded (hidden) and in memory, you can
pick up all the necessary values from this form (see above sequence)
and after the actions have taken place, and the form is no longer required
unload it from memory.

If the answer to #2 is not what you were after, kindly elaborate a bit more
on frmOutAddress needing to be active.

Krgrds,
Perry



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



Sat, 27 Aug 2005 07:05:43 GMT  
 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



Sat, 27 Aug 2005 10:31:05 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Variable(s) Reset by Showing 2nd UserForm on top 1st UserForm

2. Passing a Variable from one Userform to another Userform

3. !! userform / variable question !!

4. Two UserForm Questions

5. Two userform questions

6. two questions on how to get data entries in userforms into bookmarks (if possible at all)

7. Two userform questions

8. Userform variable question

9. UserForm To UserForm

10. Displaying Another UserForm when click on CheckBox in UserForm


 
Powered by phpBB® Forum Software © phpBB Group