Expert needed: Passing textbox contents to new form

S

Steve-o

I need to pass the Value of a textbox to the text box of
another form.

For example, I've opened up MyForm which contains 25
textboxes. My cursor is sitting in MyTextBox20. When I
hit a key combination (Ctrl-Alt-F2), I need to take the
Value of the current textbox (MyTextBox20.Value) and pass
it to MyPopUpForm to be displayed in a new textbox
(MyPopUpTextBox.Value).

I know I need to use Me somewhere in there, but not sure
exactly how.
 
T

Tim Ferguson

My cursor is sitting in MyTextBox20. When I
hit a key combination (Ctrl-Alt-F2), I need to take the
Value of the current textbox (MyTextBox20.Value) and pass
it to MyPopUpForm to be displayed in a new textbox
(MyPopUpTextBox.Value).

Private Sub MyTextBox20_KeyPress()

If keypress = <ctrl-alt-F2> Then

Forms!MyPopUpForm.Controls!MyPopUpTextbox.Value = _
Me!MyTextBox20.Value

End If

End Sub


.... or have I missed something?


Tim F
 
C

Chris

If you are using AutoKeys, and want to know which control has the focus,

Screen.ActiveControl

Then you can do Screen.ActiveControl.Value and you will get the value of
that control.
 
S

Steve-o

Yes, that will work for that one single control. BUT I
have 50 forms with 25 controls on each form, I'm not
interested in coding for each control on each form. I'll
try Chris' solution, sounds like it will do the trick.

Steve.
 

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