Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Rose Howard   on Nov 26 In MS Office Category.

  
Question Answered By: Tomas Thompson   on Nov 26

I would like very much to help you but I do not completely understand what you
want to do.
Could you please explain in simple terms.
How many userforms do you have in your project?
Do you know the name of the form  you are trying to open? These are the most
important points to clarify. Accessing the caption  property of a form is very
simple if you identify the form clearly.

Of course you can identify a form by a variable  name. -as you read in the
article you quoted.
Suppose you have two forms. one of them is called "FrmStart" and the other
"FrmContinue".
Now, according to certain actions (x <> 1 in this example) you decide to open
"FrmContinue"
if x = 1 then
strFormName = "FrmStart"
else
strFormName = "FrmContinue"
now you can call your form with the following:
VBA.UserForms.Add(strFormName).Show

If you want to change the caption of the displayed form, you can do one of the
following:
if the new caption who want is the name of the form & some other string
you do the following in the initialize event of the form (in the module form):

Private Sub UserForm_Initialize()
Me.Caption = Me.Name & " hello"
End Sub
Now, if the caption you want is a string  variable. I do not know how to pass
this string as an argument to the initialize event of the form but I believe
that you can declare this variable in one of your module (for example in
"thisworkbook" module. Declare it as public (so that you may see it from other
modules in the project and in the initialize event of the form use the
following. (in this case use Public strA_String as string in the ThisWorkbook
module)

me.caption = strA_String & " Hello"

I hope it's clear.

And by the way, if somebody knows of a better solution in order to pass an
argument to a form I would be very grateful to learn about it.

Share: 

 

This Question has 4 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Changing Caption of form by name at runtime Or get search suggestion and latest updates.


Tagged: