Is there a way to hide a form when you have the form's name stored in a variable? Obviousely, this doesn't work, but maybe this will help you understand:
Yes... that seems to work when I have the INDEX (an integer) of the Form I want to hide, but not the NAME (a string). Is there anyway to use the NAME (vs. INDEX) in a variable to hide a forn or get the INDEX from the NAME held by a variable so that the above technique can be used?
This function returns a form's index if it's open or -1 if it's not, paste it into a module and then you can use it in your code:
[tt]
Function FindFormIndex(FormName As String) As Integer
Dim i As Integer
'Use For to find form index
For i = 0 To (Forms.Count - 1)
If Forms(i).Name = FormName Then
FindFormIndex = i
Exit Function
End If
Next i
'Return -1 if form is not loaded
FindFormIndex = -1
End Function
[/tt]
You could use it like this, though it would error if the form wasn't loaded so you should trap for that:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.