Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Active user form
Hi,
On a user form (1) I have a combo box click event that activates another user form (2) to show (vb modeless) . I have both userforms showing simultaneously in different positions on the sheet. The first user form is a product entry form and the second user form displays specifications relating to the product selected in the combo box on user form 1. The first problem I have is that I want the focus to remain on user form1 (text box2 to be specific). I am not sure how to have the second user form show without the focus leaving the first form. Is this possible? The second problem is that if I make another selection on the combo box (ufrm1) while both forms are shown (modeless) I then have to close and then re-open user form 2 in order to update the values on the form. I should explain ufrm 1 combo box click writes a value to my worksheet and ufrm 2 looks up the value on another sheet and displays the relative data. I know it would be a simple solution to have everything on the same userform but this is not feasible with the layout of my sheet and it would great if someone could help me find a way around this. Regards gregork |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Active user form
To keep Userform1 active after displaying Userform2, use code
like the following: Private Declare Function FindWindow Lib "user32" _ Alias "FindWindowA" (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Declare Function SetForegroundWindow Lib "user32" _ (ByVal HWnd As Long) As Long Private Sub CommandButton1_Click() Dim HWnd As Long HWnd = FindWindow("ThunderDFrame", Me.Caption) UserForm2.Show vbModeless If HWnd Then SetForegroundWindow HWnd End If End Sub For your second question, create a public procedure in Userform2 that will update the controls, and call the procedure from a control in Userform1. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "gregork" wrote in message ... Hi, On a user form (1) I have a combo box click event that activates another user form (2) to show (vb modeless) . I have both userforms showing simultaneously in different positions on the sheet. The first user form is a product entry form and the second user form displays specifications relating to the product selected in the combo box on user form 1. The first problem I have is that I want the focus to remain on user form1 (text box2 to be specific). I am not sure how to have the second user form show without the focus leaving the first form. Is this possible? The second problem is that if I make another selection on the combo box (ufrm1) while both forms are shown (modeless) I then have to close and then re-open user form 2 in order to update the values on the form. I should explain ufrm 1 combo box click writes a value to my worksheet and ufrm 2 looks up the value on another sheet and displays the relative data. I know it would be a simple solution to have everything on the same userform but this is not feasible with the layout of my sheet and it would great if someone could help me find a way around this. Regards gregork |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Active user form
Hi Chip,
Many thanks Chip the code works brilliantly well. I really didn't think there was a way to do that. Kind Regards gregork "Chip Pearson" wrote in message ... To keep Userform1 active after displaying Userform2, use code like the following: Private Declare Function FindWindow Lib "user32" _ Alias "FindWindowA" (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Declare Function SetForegroundWindow Lib "user32" _ (ByVal HWnd As Long) As Long Private Sub CommandButton1_Click() Dim HWnd As Long HWnd = FindWindow("ThunderDFrame", Me.Caption) UserForm2.Show vbModeless If HWnd Then SetForegroundWindow HWnd End If End Sub For your second question, create a public procedure in Userform2 that will update the controls, and call the procedure from a control in Userform1. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "gregork" wrote in message ... Hi, On a user form (1) I have a combo box click event that activates another user form (2) to show (vb modeless) . I have both userforms showing simultaneously in different positions on the sheet. The first user form is a product entry form and the second user form displays specifications relating to the product selected in the combo box on user form 1. The first problem I have is that I want the focus to remain on user form1 (text box2 to be specific). I am not sure how to have the second user form show without the focus leaving the first form. Is this possible? The second problem is that if I make another selection on the combo box (ufrm1) while both forms are shown (modeless) I then have to close and then re-open user form 2 in order to update the values on the form. I should explain ufrm 1 combo box click writes a value to my worksheet and ufrm 2 looks up the value on another sheet and displays the relative data. I know it would be a simple solution to have everything on the same userform but this is not feasible with the layout of my sheet and it would great if someone could help me find a way around this. Regards gregork |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Active X Controls Tabbing from Form Field 2 Form Field | Excel Discussion (Misc queries) | |||
How do I fill a cell in a user form from a selection on same form? | Excel Discussion (Misc queries) | |||
Active Form during Execution | Excel Discussion (Misc queries) | |||
Show user form, leave wosksheet active | Excel Programming | |||
I am looking to see if anybody has an equivalant user form to Outlooks CONTACT form | Excel Programming |