can't find the form frm012Menu' referred to in a macro expression or VB code.

The code attached works for a form called frm010Login but not for a form called from102Menu (or quite a lot of other forms).  

Any ideas.

Thanks in advance
Public Function Test3()
   Dim frm As Form, ctl As Control, s As String
   Set frm = Forms!frm012Menu
   For Each ctl In frm
      Debug.Print ctl.Name
   Next ctl
End Function

Open in new window

Clive BeatonAccess DeveloperAsked:
Who is Participating?
peter57rConnect With a Mentor Commented:
The form you are referring to must be open.
if thats the name of your form, put it in quotes, does it make a difference?

set frm = forms("frm012Menu")
rockiroadsConnect With a Mentor Commented:
ah, it just clicked

form isnt open therefore it cant find it

so open the form, you can open it hidden also

eg open form for edit but hidden

    DoCmd.OpenForm "form1", acDesign, , , acFormEdit, acHidden

Clive BeatonAccess DeveloperAuthor Commented:
Thanks, Guys.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.