Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2004

Tip: Looking for answers? Try searching our database.

passing information

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
phil - 17 Nov 2004 21:47 GMT
what is the best solution to pass information from one userform to another
userform
thanks phil
Jean-Guy Marcil - 17 Nov 2004 21:59 GMT
phil was telling us:
phil nous racontait que :

> what is the best solution to pass information from one userform to
> another userform

It depends on the context, the goal and the end-result you are after.
Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Perry - 17 Nov 2004 22:11 GMT
Depends on the situation.
But here's a general rule:Keep the (inactive) userform loaded/in memory and
you can pick up the values of the controls
in the active userform, as in:

(whereby Userform1 as the inactive userform, and Userform2 is the active
one)

(code from userform2's codemodule, and "txtU" is a control on userform1 and
"txtCurrent" is
a textbox on the active userform "userform2")

Dim u as userform1
Me.txtCurrent = u.txtU

(note: as stated previously, userform1 represented by objectvariable "u" and
is still in memory in above code sequence)

How can you keep a userform in memory?
Don't "Unload", in situations where you want to keep the userform in memory,
instead "Hide" the userform in question
and unload it (for instance) after you've gathered all information from the
userform in question.

Repost if you have problems implementing above suggestion, indicating the
violating lines of code.

Krgrds,
Perry

> what is the best solution to pass information from one userform to another
> userform
> thanks phil
phil - 18 Nov 2004 11:00 GMT
looking at this solution my main problem is the userforms are quite large
and I prefer not to store the inactive userform in memory as this will slow
things down is there a way to store this info in a variable and then recover
this information when the second userform is opened

thanks phil

> Depends on the situation.
> But here's a general rule:Keep the (inactive) userform loaded/in memory and
[quoted text clipped - 29 lines]
> > userform
> > thanks phil
Perry - 18 Nov 2004 22:06 GMT
Sure
Declare the variables publically in a standard module, and they will "stay
alive" during
the course of runtime.

<Standard code module - general declaration section>
Public MyVar As String

<code module of first userform>
MyVar = Me.TextBox1    'passing value from a control to variable

After the value has been passed, you can unload the first userform
load the second one and pass the variable ...

<code module of second userform>
Me.OtherTextBox = MyVar    'passing variable to second userform

Krgrds,
Perry

> looking at this solution my main problem is the userforms are quite large
> and I prefer not to store the inactive userform in memory as this will slow
[quoted text clipped - 42 lines]
> > > userform
> > > thanks phil
phil - 19 Nov 2004 11:36 GMT
hi Perry
thanks for the advice
just one thing for each textbox I wish to transfer info from I need to
declare as a variable
so in code module I declare Public MyVar1 As String for text box 1 then
Public MyVar2 As String for text box 2
and so one is this correct
thanks phil

> Sure
> Declare the variables publically in a standard module, and they will "stay
[quoted text clipped - 65 lines]
> > > > userform
> > > > thanks phil
Perry - 19 Nov 2004 19:48 GMT
Can't tell how yr project looks like and whether you have to reckon with
other possible pitfalls but based on the information you provided:

Looks ok, yep

Krgrds,
Perry

> hi Perry
> thanks for the advice
[quoted text clipped - 80 lines]
> > > > > userform
> > > > > thanks phil
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.