Open form from custum menubar item using functions

hawg1

Registered User.
Local time
Today, 16:32
Joined
Sep 24, 2006
Messages
51
Hi,

I'm starting to work with modules and need some help with functions. I have created a custom menubar with menus like File, Admin, Reports, etc. I would like to have my top level Admin form, for example, open when I click on 'Admin' in the menu bar.

I think this can be done with a public function, but not sure. I would like to set up some generic function so I can use the same module to open other forms as well.

Any tips or pointer would be most welcome

Thanks
 
You can create a function like:
Code:
Public Function OpenMyForm(strForm As String)
  Docmd.OpenForm strForm acNormal
End Function
 
You can create a function like:
Code:
Public Function OpenMyForm(strForm As String)
  Docmd.OpenForm strForm acNormal
End Function

Boblarson,

This is what I originally had, but it doesn't seem to work. I created a menu command named 'personnel' and added '=OpenMyForm("fTest")' to the On Action box within the commands property menu. I get a message stating that 'The expression you entered has a function name that Microsoft Access can't find.'

Am I doing something incorrectly?
 
And you placed the code in a STANDARD module and not a form's module?
 
And you placed the code in a STANDARD module and not a form's module?

BobLarson,

I finally figured it out. I was using the module name and not the function name in the menu bar command. Changed the names and everything is A OK.

:p Thanks for the help and quick responses!
 

Users who are viewing this thread

Back
Top Bottom