Return a string based on which Textbox is clicked

A

Andy

Hi there,

I have a form with text boxes on different pages.

When a user clicks some of these boxes another form pops up displaying
a calendar which is used to fill the aforementioned textbox.

This is all fine and good but I need to pass a variable on to the
calendar form to tell it which textbox to fill in.


So basically I'm having trouble finding a way to capture which textbox
was clicked on one form and passing that information on to the other
form.

Any help would be appreciated!
 
W

Wouter HM

Hi Andy,

I dit not compleetly build your situation.
I created 1 module with:

Public clickedBox As Control

I created 2 forms
On form 1 two textboxes.
For the textboxes I filled the Tag property with something.
And with the code:

Private Sub TextBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Set clickedBox = Me.TextBox1
UserForm2.Show
End Sub

Private Sub TextBox2_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Set clickedBox = Me.TextBox2
UserForm2.Show
End Sub

On Form2 1 Label, 1 Textbox and 2 buttions ( OK and cancel)
And with the code:


Private Sub Cancel_Click()
Me.Hide
End Sub

Private Sub cmdOK_Click()
clickedBox.Text = Me.TextBox1.Text
Me.Hide
End Sub

Private Sub UserForm_Activate()
Me.Label1.Caption = clickedBox.Tag
Me.TextBox1.Text = clickedBox.Text
End Sub


HTH,

Wouter
 
A

Andy

Wouter,

With your clear examples I could modify my code to work as needed, so
thank you very much!

Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top