H
Hendy88
Hello to all,
In my code, I have a variable that represents the name of a UserForm
that will be opened as a result of a call to a function. However,
what I have errors out with "this object does not support this
property or method". How can I open the appropriate existing form
based on this string representing the form name?
This is what I currently have:
Dim FormName As String
FormName = "FieldUserForm"
FormStuff FormName
Function FormStuff(FormName As String)
With FormName
.Show
.Textbox1.Visible = False
.Textbox2.Visible = False
.Textbox3.Visible = True
.Textbox4.Visible = False
.Textbox5.Visible = True
End With
End Function
I've tried even making the Dim variable "As UserForm" but that didn't
work either. Any ideas? Or should I be going about this a different
way? Reason I want the separate function is because there are more
than one UserForms that I want to show at different stages in the
macro. So later on I want to call the same function with a different
UserForm name:
FormName = "OfficeUserForm"
FormStuff FormName
Thanks in advance!
In my code, I have a variable that represents the name of a UserForm
that will be opened as a result of a call to a function. However,
what I have errors out with "this object does not support this
property or method". How can I open the appropriate existing form
based on this string representing the form name?
This is what I currently have:
Dim FormName As String
FormName = "FieldUserForm"
FormStuff FormName
Function FormStuff(FormName As String)
With FormName
.Show
.Textbox1.Visible = False
.Textbox2.Visible = False
.Textbox3.Visible = True
.Textbox4.Visible = False
.Textbox5.Visible = True
End With
End Function
I've tried even making the Dim variable "As UserForm" but that didn't
work either. Any ideas? Or should I be going about this a different
way? Reason I want the separate function is because there are more
than one UserForms that I want to show at different stages in the
macro. So later on I want to call the same function with a different
UserForm name:
FormName = "OfficeUserForm"
FormStuff FormName
Thanks in advance!