How to get info from one form to another while both are open?

  • Thread starter Thread starter plh
  • Start date Start date
P

plh

What I want to do is append strings in the most recently clicked
textbox control in one form (call it Form1), based on actions taken
(in this case, labels clicked) in another (call it Form2). What's the
cleanest way to do this? I can't really use OpenArgs because that
would be closing and re-opening the forms. The activate and
de-activate events look promising, but they seem promising, but I
wondered if there is a more direct way. One complication is that to
see Form2 for the first time, the user has to click a command button,
and so, the text box is no longer the active control.
Thank You,
-plh
I keep hitting "Esc" -- but I'm still here!
 
plh said:
What I want to do is append strings in the most recently clicked
textbox control in one form (call it Form1), based on actions taken
(in this case, labels clicked) in another (call it Form2). What's the
cleanest way to do this? I can't really use OpenArgs because that
would be closing and re-opening the forms. The activate and
de-activate events look promising, but they seem promising, but I
wondered if there is a more direct way. One complication is that to
see Form2 for the first time, the user has to click a command button,
and so, the text box is no longer the active control.
Thank You,
-plh
I keep hitting "Esc" -- but I'm still here!

You'll have to pick the appropriate event for the code, but
you can make direct form-to-form assignments.

Forms!SomeOtherFormName!SomeOtherControl = Me!SomeControl
 
Hi

To put the focus back to the textbox when clicking the button to open form2
use the following;

Screen.PreviousControl.SetFocus
DoCmd.OpenForm "Form2"{, any other arguments}

But you don't really need to do this - pass the name of the previous control
for Form 2 using the OpenArgs parameter

DoCmd.OpenForm "Form2", , , , , , Screen.PreviousControl.Name

Then in Form 2 when you want to append;

Forms![Form1].Controls(Me.OpenArgs).Value = _
Forms![Form1].Controls(Me.OpenArgs).Value & _
vbcrlf & "Other Stuff"

HTH

Andy
 
Back
Top