CurrentUser MenuBar

G

Guest

If I want to have a custom menubar startup when a certain user logs in, where
would I write this code? Can I put it into a module? If so, how do I get it
to run when the db is opened?
 
T

tina

you could put the code in the Open event procedure of the form that opens
when your database opens (like a login form, or main menu, whatever). or you
could put the code in a standard module, and call it from an AutoExec macro,
which runs automatically when the database opens.

hth
 
G

Guest

Tina,
I tried to put it into a module and call it from an AutoExec macro but it
wouldn't work. I just created a function in a module and then called the
function name. Is that correct?
 
T

tina

yes. make sure you're using the RunCode action in the macro. make sure your
code is defined as a Function, not as a Sub, and is in a standard module
(not a form or report module). read up on the RunCode action in Access Help,
to make sure you're using the correct syntax in the FunctionName argument.

hth
 
G

Guest

I have it defined as a function. The function name is"Function CustomMenu()".
I created a AutoExec macro and used the RunCode action. Then I typed in the
code as "CustomMenu()". But it's still not working. Am I missing something
else?
 
T

tina

i'm not sure it will make a difference, but did you write the function in
the module specifically as

Public Function CustomMenu()

using "Public"? also, when you say it "doesn't work", what does that mean?
is the macro running, or not? if the function running, or not? are you
getting an error message, or nothing?

hth
 
G

Guest

Hi Tina,
It seems to be working now. Maybe I was misspelling it or something. I'm not
using the work "Public" as part of the function line. Does that matter?
 
G

Guest

I figured out what I did wrong. I renamed the module to "CustomMenu" from
"Module2". I wasn't aware that I couldn't do that without calling that name
out. Is that correct?
 
T

tina

I figured out what I did wrong. I renamed the module to "CustomMenu"
from "Module2".

well, the name of the module shouldn't matter - except that it cannot be the
same name that's used as the name of any procedure that's contained in the
module; Module2 should have been fine as a module name - it's just an Access
default name.
I wasn't aware that I couldn't do that without calling that
name out.

sorry, hon you lost me there; i have no idea what you mean.
I'm not using the work "Public" as part of the function line.
Does that matter?

perhaps not; i just make a point of explicitly declaring my procedures as
Private or Public - then i don't have to worry about it.

hth
 
G

Guest

That's what I did wrong. I used the same name as the function. Now I know
what not to do next time. Thanks for helping out! Appreciate it!
 
T

tina

you're welcome :)


Secret Squirrel said:
That's what I did wrong. I used the same name as the function. Now I know
what not to do next time. Thanks for helping out! Appreciate it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top