Autoexec with forms not working

danikuper

Registered User.
Local time
Today, 06:45
Joined
Feb 6, 2003
Messages
147
Hi,

I'm trying to get specific forms to open automatically based on the user that is using the database. I tried creating an Autoexec macro and having the following as parameters:

Action: open form
Form name: Welcome John
View: Form
Where condition: CurrentUser()=[john]
Window Mode: Normal

The form "Welcome John" does open when john logs in however it will open all the time regardless of the user (when mary logs in she also receives the same form, which should not happen).

Initially I thought it was something to do with my command currentuser however I tried other combinations like:

CurrentUser()="john"
CurrentUser()='john'

And none of those seem to work... what am I doing wrong?
 
The correct way to call it is...

If CurrentUser = "john" Then

You must be using true Access security with workgroups and user permissions for the CurrentUser function to work (return the users workgroup name).

As a test, have the users open a form on their machine with this message box in the OnOpen event to see what their user name is for that machine and/also how they logged into the db with...

MsgBox "CurrentUser = " & CurrentUser

HTH
 
Humm.... by using the MsgBox "CurrentUser = " & CurrentUser I see that my users are indeed loging correctly and that I have their correct usernames.

Maybe I was not clear when I explained my problem. I don't want to add the call on my form but would rather have it on the Autoexec macro so the first thing my user will see is the form related to his function (which is based on his name).

I'm using Access 2000 and it does not allow me to add an IF statement when writing macros... or maybe I'm doing something wrong :confused:

Any ideas?

thanks!
 
I do not use macros (no error trapping!). I would have a hidden form open that tests for your users in the OnOpen event and then displays the correct form for each user.

HTH
 
I created a form to do the work of the autoexec macro the way you suggested and it works!!! Didn't think about that before...

Thanks a lot! :)
 
Did you try the conditonal part of the Macros?
That basically works as an IF statement in the macro.
 
Yes! I tried the conditional part o the macro (there's a WHERE field) but it didn't work, I don't know why.
 

Users who are viewing this thread

Back
Top Bottom