I am trying to create a routine that opens a form at a specific location. I have
Sub OpenForm(Name$, Left_, Top_)
DoCmd.OpenForm Name$
If (Left_ <> 0) Or (Top_ <> 0) Then
Forms!Name$.Move Left_, Top_
End If
End Sub
Sub Test02()
OpenForm "Form2", 1000, 1000
End Sub
Every time I run Teso02 I get an error msg saying that there is no form named Name$.
I realize one workaround would be to use global variables
Public FormTop as Integer, FormLeft as Integer and get
Sub OpenForm(Name$, Left_, Top_)
FormLeft = Left_
FormTop = Top_
DoCmd.OpenForm Name$
End Sub
and put the following in the codefile of Form2 and all other forms
Private Sub Form_Load()
If (FormTop <> 0) or (FormLeft <> 0) then
Me.Move FormLeft, FormTop
EndIf
End Sub
But I suspect there's a way to reference the form whose name is contained in variable Name$ from code outside the form's codefile. If someone knows how to do this I'd appreciate hearing about it.
Thanks in advance.