Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Active X Controls Tabbing from Form Field 2 Form Field Tfrup12 Excel Discussion (Misc queries) 0 February 19th 08 08:15 PM
How do I fill a cell in a user form from a selection on same form? Terry Tipsy Excel Discussion (Misc queries) 4 June 11th 07 02:59 PM
Active Form during Execution BillCPA Excel Discussion (Misc queries) 0 August 11th 06 03:15 PM
Show user form, leave wosksheet active Wric Smith Excel Programming 3 December 4th 03 08:46 PM
I am looking to see if anybody has an equivalant user form to Outlooks CONTACT form BruceJ[_2_] Excel Programming 2 October 15th 03 05:28 PM


All times are GMT +1. The time now is 05:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"