Re: Getting NT User Login Names from Access 2000 or 2003

Tech-Archive recommends: Fix windows errors by optimizing your registry



I tried to post the code:
Option Compare Database
Private Declare Function apiGetUserName Lib "C:\WINNT\system32\advapi32.dll"
Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Private Sub Form_Open(Cancel As Integer)
Dim strUserName As String
strUserName = fOSUserName()
MsgBox strUserName

End Sub
and got an error in my reply to you and the reply has no code.
Tryng the code, above, again.
--
MichaelM


"Jeff Conrad" wrote:

> Humor me here.
>
> Create a new blank form and put this code in the Open event.
>
> Private Sub Form_Open(Cancel As Integer)
> MsgBox fOSUserName()
> End Sub
>
> What does the message box say?
> Any extra spaces?
>
> --
> Jeff Conrad
> Access Junkie
> http://home.bendbroadband.com/conradsystems/accessjunkie.html
> http://www.access.qbuilt.com/html/articles.html
>
> "Michael Miller" wrote in message:
> news:3B25DD23-EBE4-4137-B56D-C2605A855261@xxxxxxxxxxxxxxxx
>
> > Nothing is missing and it does find MMILLER, but has over 200 spaces after it.
> > The additional spaces will not allow it to be assigned to a field.
> >
> > This code does match the user name with a string value tho, even given the
> > spaces:
> > Select Case LCase(fOSUserName())
> >
> > Case "mmiller"
> > cmdDeveloperClose.Visible = True
> > cmdStarsUpdate.Visible = True
> > lblHello.Visible = True
> > lblHello.Caption = lblHello.Caption & " Michael"
> >
> > --
> > MichaelM
> >
> >
> > "Jeff Conrad" wrote:
> >
> > > Sounds like maybe a References problem. See:
> > >
> > > http://home.bendbroadband.com/conradsystems/accessjunkie/references.html
> > >
> > > Post back with results.
> > > --
> > > Jeff Conrad
> > > Access Junkie
> > > http://home.bendbroadband.com/conradsystems/accessjunkie.html
> > > http://www.access.qbuilt.com/html/articles.html
> > >
> > > "Michael Miller" wrote in message:
> > > news:2A04C5B6-B320-48AC-AFA7-96FE3B0F571F@xxxxxxxxxxxxxxxx
> > >
> > > > I have a function called fOSUserName, that I found, to get the login name of
> > > > the person, when they open my main form.
> > >
> > > [code snipped]
> > >
> > > > Problem is that it's returning mmiller followed by a bunch of square boxes.
> > > > The Left$ (in the code) and a try of Trim and a LTrim(RTrim()) is not fixing
> > > > it. When I try to assign it to a field in a log table, it always says that
> > > > my data is too big for the field.
> > > > When I assign it to a label, it shows up fine, as the boxes are not visible.
> > >
> > >
> > >
>
>
>
.



Relevant Pages

  • Re: Playing AVI and MPEG using MCI
    ... "mciSendStringA" (ByVal lpstrCommand As String, ... Dim mlRet As Long ... Private Sub CenterObject ... If mlRet 0 Then ...
    (microsoft.public.vb.controls)
  • RE: Adding Bound Pictures to an Access Database
    ... when the student's picture is missing it is leaving the ... Private Sub Form_Current ... Dim strPath As String ... Private Function pfValidFile(aFile As String) As Boolean ...
    (microsoft.public.access.modulesdaovba)
  • RE: jpgs not showing on forms
    ... Rather than embed the pictures in the database store the paths to the JPEG ... Private Sub cmdAddImage_Click ... Dim strAdditionalTypes As String, strFileList As String ... Private Sub cmdDeleteImage_Click ...
    (microsoft.public.access.gettingstarted)
  • Re: how to digitally sign XML documents step by step
    ... Add an XML node. ... >Private strPath As String ... >'The ControlID for the first control you add will be 1. ... >Private Sub ISmartDocument_PopulateActiveXProps(ByVal ControlID As Long, ...
    (microsoft.public.word.vba.general)
  • Re: how to digitally sign XML documents step by step
    ... Private strPath As String ... 'The ControlID for the first control you add will be 1. ... Private Sub ISmartDocument_PopulateActiveXProps(ByVal ControlID As Long, ... Dim strImage As String ...
    (microsoft.public.word.vba.general)