Jnana:

I have a slightly different function to do the same thing (uses a 
different DLL for the API call).  I tested it in Access (I had gotten 
it originally for my standalone VB-6 IDE) and it works:

In the General Declarations section of the form, put the following:
'==================================================================
Private Declare Function GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
'===================================================================

Then code the Form_Load() statement as follows:

==================================================================
Private Sub Form_Load()
Dim cn As String
Dim ls As Long
Dim res As Long
cn = String(1024, 0)
ls = 1024
res = GetUserName(cn, ls)
If res <> 0 Then
MsgBox "You are logged in as " & " " & Mid(cn, 1, InStr(cn, Chr(0)) - 
1)
Else
MsgBox "You are not logged in"
End If
End
End Sub
==================================================================

I just tested this in Access 2002 (Office XP Pro) and it worked.

Hope this helps!

Richard




--- In [email protected], "owen_group_profile" 
<[EMAIL PROTECTED]> wrote:
> yep, Richard's correct.  Details can be found at:
> 
> http://support.microsoft.com/?kbid=161394
> 
> hth,
> Owen
> 
> 
> 
> --- In [email protected], "Richard" <[EMAIL PROTECTED]> 
wrote:
> > I am assuming that you mean the windows login name.  There is a 
system 
> > variable for this.  Do a search in the VBA help  (may be an API 
> > function - I am not on my computer with Access at the moment).
> > 
> > Hope this helps!
> > 
> > Richard
> > 
> > 
> > 
> > --- In [email protected], "jsivanan" 
<[EMAIL PROTECTED]> 
> > wrote:
> > > Hi!
> > > I need the current user id to determine the pathname of "My 
> > Documents".
> > > Anybody know how to extract it from the system while in Access 
VB?
> > > Specifying "C:\My Documents\filename" didn't generate an error, 
but
> > > the file couldn't be found.
> > > 
> > > Just leaving out "C:\My Documents" works sometimes because it 
> > > defaults, but several times it went to the desktop!!! 
> > > 
> > > Thanks in advance for your help.
> > > 
> > > Jnana




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/q7folB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AccessVBACentral/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to