Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

user forms

  Asked By: Nancy    Date: Dec 21    Category: MS Office    Views: 696
  

I'm pretty new to user forms, so this may be a ridiculous question, but bear
with me:

The general issue is whether or not it's possible for a code module to see
the values of parts of a user form. For example, if I have a text box in my
user form in which the user enters a date, is there any way to get a
function or subroutine from Module1 to be able to read
UserForm1.TextBox1.Value and process it, or should I just put all
subroutines that will deal with the user form in the user form code module?

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Luete Fischer     Answered On: Dec 21


I don't think there should be any problem with that.
I'm not certain, but the Userform's Showmodal property may have to be
set to False.

 
Answer #2    Answered By: Bodhi Smith     Answered On: Dec 21

As long as your userform is loaded you can retrieve information from any module.
You just have to specifically identify the userform and the control.
from module1 you will call for example
sub myProcedure
msgbox userform1.textbox1.text
end sub

from the userform you can call procedure in any module  for example:
call module1.myProcedure

If you unload the userform, the information it contained will be lost.
Hope this helps

 
Answer #3    Answered By: Charlotte Brown     Answered On: Dec 21

I do it all the time. What you'll
probably want to do is just hide the form  so it stays loaded, but gets out
of the way. You can unload it later, before you bail the app...although it
SHOULD be unloaded when the app closes. But I prefer to unload stuff with
code just to make sure.

Also, if you're activating a sub from an OK click in a form, although it's
not always necessary, I generally enter the mod name first...mostly because
it helps me more easily remember the sub's name.

In other words, say the user  clicks OK and info from a dialog box  is going
to go into a doc. I might hide the form, and call the sub to process  the
info, like...

modMain.FillDoc

Not so much because it needs the extra kick to find the sub, but because I
might forget the exact name, so I'll get a list once I hit the period after
modMain.

Once the info is inserted in the doc, I unload the form before the sub ends.

This is handy for having a code  library mod that you can easily move into a
project and then call your standard subs for processing.

 
Didn't find what you were looking for? Find more on user forms Or get search suggestion and latest updates.




Tagged: