Referencing a form by name?

Kowalski

Registered User.
Local time
Today, 15:01
Joined
Jul 5, 2007
Messages
121
Hi
Funny thing in Access 2010.
I've got a form open:
mystring = Forms(5).Caption 'This works, but
mystring = Forms("MyFormName").Caption 'This tells me it can't find my form, and
mystring = Forms!MyFormName.Caption 'also doesn't work

And yes, Form(5)'s name is MyFormName.

Why so?
 
Last edited:
Admittedly this is Access 2007 but you can try this Function:
Code:
Function Clients_Close()
    With CodeContextObject
        DoCmd.Close acForm, .Name
    End With
End Function
Simon
 
Thanks, but I just opened the form with code. Can't close it again.
Solution is to not open it using a form reference variable.
 

Users who are viewing this thread

Back
Top Bottom