Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / September 2006

Tip: Looking for answers? Try searching our database.

Default CurrentUser when not opening form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Carl Colijn - 12 Sep 2006 16:22 GMT
Hi group,

I found a peculiar situation with my database.  When I first use CurrentDB
and then show Workspaces(0).UserName in a MsgBox, I get the name of the
logged in user.  However, when I do not first access CurrentDB and ask for
the value of Workspaces(0).UserName right away, I get "admin"...  Further
investigation reveals that "admin" really is the logged in user from then
on, at least as far as Access is concerned.  When I insert the following
code:
   Dim oThisDB As DAO.Database
   Set oThisDB = CurrentDb
right before the part where I start using Workspaces(0), all is fine and the
correct current user is recognized again...

Sometimes in my code I first use Workspaces(0) to get some things done
before using CurrentDB.  And since "admin" has no rights on my database, all
my error routines get triggered.  I know I can work around this issue by
first asking for CurrentDB, but I wondered what might be going on...  Is
this by design or is there something else going on?  I use Access 2003,
Dutch edition, and the current user logs in via a shortcut that specifies
the workgroup, username and password.

Thanks in advance,
Carl Colijn
Lynn Trapp - 12 Sep 2006 16:54 GMT
Try using the CurrentUser() function in the place of Workspaces(0).UserName.

Signature

Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html

> Hi group,
>
[quoted text clipped - 20 lines]
> Thanks in advance,
> Carl Colijn
Carl Colijn - 12 Sep 2006 17:38 GMT
>> Hi group,
>>
[quoted text clipped - 22 lines]
> Try using the CurrentUser() function in the place of
> Workspaces(0).UserName.

Hi Lynn,

Well, it's not that I need the name of the CurrentUser, but I need to use
the default workspace (Workspaces(0)).  And directly accessing the default
workspace before accessing CurrentDB results in "admin" being the current
user from then on during the rest of the session, in stead of the actually
logged in user.  And it's not only that the name is wrong; the code also
operates under the credentials of the "admin" user (which is locked out of
the DB in my case).

Any ideas?  For now I execute the function
   Public Function SetCorrectUser() As Boolean
       Dim oThisDB As DAO.Database
       Set oThisDB = CurrentDb
       SetCorrectUser = True
   End Function
in an AutoExec macro (which also does the trick).  But I'd rather not have
to rely on this workaround...

Kind regards,
Carl Colijn
Lynn Trapp - 12 Sep 2006 17:54 GMT
Carl,
Without using the CurrentDB reference you aren't going to know the user
logged in to Workspaces(0). However, CurrentUser() should return the logged
in user regardless.

Signature

Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html

>>> Hi group,
>>>
[quoted text clipped - 44 lines]
> Kind regards,
> Carl Colijn
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.