Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Passing a value from one userform to another (multiple) form

I have two userforms, form A and form B. Form A contains 10 textboxes
(txtbox1, txtbox2, ..., txtbox10), and form B contains a combobox and an OK
button.

What I want to achieve is as follow: whenever the user click one of the ten
textboxes if form A, form B will show. The user then select one value from
the combobox, click OK, and the selected value will be sent to the textbox
that was clicked initially. How do I make form B to recognize which textbox
that was clicked by the user?

P.S. Obviously, it will be easier if I can replace the ten textboxes in form
A with comboboxes, and eliminate the need to have form B altogether, but
unfortunately I do not have enough space in form A to do that. Each entry in
the combobox consist of 4 numbers followed by a description, and the
textboxes in form A have just enough width to show only the numbers.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Passing a value from one userform to another (multiple) form


Userform1


Public TB As MSForms.TextBox

Private Sub TextBox1_Enter()
Set TB = Me.TextBox1
UserForm2.Show
End Sub

Private Sub TextBox2_Change()
Set TB = Me.TextBox2
UserForm2.Show
End Sub

Userform2

Private Sub ComboBox1_Change()
UserForm1.TB.Text = Me.ComboBox1.Value
Me.Hide
End Sub



--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Ketut" wrote in message
...
I have two userforms, form A and form B. Form A contains 10 textboxes
(txtbox1, txtbox2, ..., txtbox10), and form B contains a combobox and an
OK
button.

What I want to achieve is as follow: whenever the user click one of the
ten
textboxes if form A, form B will show. The user then select one value from
the combobox, click OK, and the selected value will be sent to the textbox
that was clicked initially. How do I make form B to recognize which
textbox
that was clicked by the user?

P.S. Obviously, it will be easier if I can replace the ten textboxes in
form
A with comboboxes, and eliminate the need to have form B altogether, but
unfortunately I do not have enough space in form A to do that. Each entry
in
the combobox consist of 4 numbers followed by a description, and the
textboxes in form A have just enough width to show only the numbers.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Passing a value from one userform to another (multiple) form

Thank you very much, Bob. It really helped me.
But what if I have more than one userforms that is accessing the information
from userform 2? How do I make the combobox in userform 2 recognizes not just
the textbox that is calling calling it, but also the userform that contains
that textbox?

I tried the following:
public TB as MSforms.textbox

in userform 1: set TB = me.txtbox1

in userform 3: set TB = me.txtbox5

in userform 2: TB.value = me.combobox1.value

It didn't work :(



"Bob Phillips" wrote:


Userform1


Public TB As MSForms.TextBox

Private Sub TextBox1_Enter()
Set TB = Me.TextBox1
UserForm2.Show
End Sub

Private Sub TextBox2_Change()
Set TB = Me.TextBox2
UserForm2.Show
End Sub

Userform2

Private Sub ComboBox1_Change()
UserForm1.TB.Text = Me.ComboBox1.Value
Me.Hide
End Sub



--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Ketut" wrote in message
...
I have two userforms, form A and form B. Form A contains 10 textboxes
(txtbox1, txtbox2, ..., txtbox10), and form B contains a combobox and an
OK
button.

What I want to achieve is as follow: whenever the user click one of the
ten
textboxes if form A, form B will show. The user then select one value from
the combobox, click OK, and the selected value will be sent to the textbox
that was clicked initially. How do I make form B to recognize which
textbox
that was clicked by the user?

P.S. Obviously, it will be easier if I can replace the ten textboxes in
form
A with comboboxes, and eliminate the need to have form B altogether, but
unfortunately I do not have enough space in form A to do that. Each entry
in
the combobox consist of 4 numbers followed by a description, and the
textboxes in form A have just enough width to show only the numbers.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Passing a value from one userform to another (multiple) form

You have to qualify the TB with the form that it is on.

Which form has the TB in this example?

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Ketut" wrote in message
...
Thank you very much, Bob. It really helped me.
But what if I have more than one userforms that is accessing the
information
from userform 2? How do I make the combobox in userform 2 recognizes not
just
the textbox that is calling calling it, but also the userform that
contains
that textbox?

I tried the following:
public TB as MSforms.textbox

in userform 1: set TB = me.txtbox1

in userform 3: set TB = me.txtbox5

in userform 2: TB.value = me.combobox1.value

It didn't work :(



"Bob Phillips" wrote:


Userform1


Public TB As MSForms.TextBox

Private Sub TextBox1_Enter()
Set TB = Me.TextBox1
UserForm2.Show
End Sub

Private Sub TextBox2_Change()
Set TB = Me.TextBox2
UserForm2.Show
End Sub

Userform2

Private Sub ComboBox1_Change()
UserForm1.TB.Text = Me.ComboBox1.Value
Me.Hide
End Sub



--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Ketut" wrote in message
...
I have two userforms, form A and form B. Form A contains 10 textboxes
(txtbox1, txtbox2, ..., txtbox10), and form B contains a combobox and
an
OK
button.

What I want to achieve is as follow: whenever the user click one of the
ten
textboxes if form A, form B will show. The user then select one value
from
the combobox, click OK, and the selected value will be sent to the
textbox
that was clicked initially. How do I make form B to recognize which
textbox
that was clicked by the user?

P.S. Obviously, it will be easier if I can replace the ten textboxes in
form
A with comboboxes, and eliminate the need to have form B altogether,
but
unfortunately I do not have enough space in form A to do that. Each
entry
in
the combobox consist of 4 numbers followed by a description, and the
textboxes in form A have just enough width to show only the numbers.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Passing a value from one userform to another (multiple) form

Hi Bob, I apologize for couldn't make it clear.
Your earlier input helped me in solving my problem, but now the situation is
getting a bit more complex.

Now I have 3 userforms. Let's call them FormA, FormB, and InputForm. Both
FormA and FormB have 5 textboxes each, while InputForm has a combobox. What I
want to achieve this time is, whenever the user click any of the 10 texboxes,
the InputForm will be shown. After the user select one value from the
combobox in InputForm, this value then will be passed to the textbox that
called the InputForm.

My problem is I don't know how to make the combobox in InputForm to
recognize the form which contains the textbox that called it. I tried to to
the following:

public MyForm as UserForm
public TB as MSForms.TextBox

Then at FormA:
Private Sub TextBox1_Enter()
Set MyForm = FormA
Set TB = FormA.TextBox1
InputForm.Show
End Sub

Similarly in FormB:
Private Sub TextBox1_Enter()
Set MyForm = FormB
Set TB = FormB.TextBox1
InputForm.Show
End Sub

In InputForm:
Private Sub ComboBox1_Change()
MyForm.TB.Text = Me.ComboBox1.Value
Unload Me
End Sub

It didn't work..... :(

"Bob Phillips" wrote:

You have to qualify the TB with the form that it is on.

Which form has the TB in this example?

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Passing a value from one userform to another (multiple) form

Ketut,

Best we turn the earlier suggestion on its head

FormA

Private Sub TextBox1_Enter()
Set InputForm.TB = Me.TextBox1
InputForm.Show
End Sub

Private Sub TextBox2_Enter()
Set InputForm.TB = Me.TextBox2
InputForm.Show
End Sub

etc.

FormB

Private Sub TextBox1_Enter()
Set InputForm.TB = Me.TextBox1
InputForm.Show
End Sub

Private Sub TextBox2_Enter()
Set InputForm.TB = Me.TextBox2
InputForm.Show
End Sub

etc.



InputForm

Public TB As MSForms.TextBox

Private Sub ComboBox1_Change()
TB.Text = Me.ComboBox1.Value
Me.Hide
End Sub



--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Ketut" wrote in message
...
Hi Bob, I apologize for couldn't make it clear.
Your earlier input helped me in solving my problem, but now the situation
is
getting a bit more complex.

Now I have 3 userforms. Let's call them FormA, FormB, and InputForm. Both
FormA and FormB have 5 textboxes each, while InputForm has a combobox.
What I
want to achieve this time is, whenever the user click any of the 10
texboxes,
the InputForm will be shown. After the user select one value from the
combobox in InputForm, this value then will be passed to the textbox that
called the InputForm.

My problem is I don't know how to make the combobox in InputForm to
recognize the form which contains the textbox that called it. I tried to
to
the following:

public MyForm as UserForm
public TB as MSForms.TextBox

Then at FormA:
Private Sub TextBox1_Enter()
Set MyForm = FormA
Set TB = FormA.TextBox1
InputForm.Show
End Sub

Similarly in FormB:
Private Sub TextBox1_Enter()
Set MyForm = FormB
Set TB = FormB.TextBox1
InputForm.Show
End Sub

In InputForm:
Private Sub ComboBox1_Change()
MyForm.TB.Text = Me.ComboBox1.Value
Unload Me
End Sub

It didn't work..... :(

"Bob Phillips" wrote:

You have to qualify the TB with the form that it is on.

Which form has the TB in this example?

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)




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
Multiple fonts in a VBA UserForm label (to make XL 95 form non-modal) Anthony Berglas Excel Programming 2 August 13th 07 05:37 AM
Passing value to userform quetion Doug Glancy Excel Programming 0 December 1st 06 09:02 PM
Passing Procuedure to Userform Nigel Excel Programming 4 September 10th 05 05:22 PM
Passing variables between Sub and Userform jose luis Excel Programming 8 July 22nd 05 05:20 PM
passing control value from one form to another form mark kubicki Excel Programming 1 April 3rd 04 01:27 AM


All times are GMT +1. The time now is 02:30 AM.

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"