Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

User Name * Computer Name...

Discussion in 'Information Technology' started by ldiaz, Nov 16, 2005.

  1. ldiaz

    ldiaz
    Expand Collapse
    Guest

    Hi I'm using this code to get UserName and ComputerName of all user that
    access to my DataBase.

    this code is in the Form, also I have two modules named: fOSMachineName and
    fOSUserName , the codes of these modules wre copied from www.mvps.org but I
    don't know why it does not work,

    could you help me, I will appreciate so much

    ldiaz

    ______________________________________________
    Option Compare Database

    Private Sub form_Open(Cancel As Integer)


    On Error GoTo ErrHandler


    DoCmd.GoToRecord acDataForm, Me.Form, acNewRec

    Me!UserName.Text = fOSUserName()
    Me!ComputerName.Value = fOSMachineName()
    Me!BeginTime.Value = Now()
    RunCommand acCmdSaveRecord

    Exit Sub

    ErrHandler:

    MsgBox "Error in Form_Open( ) in" & vbCrLf & _
    Me.Name & " form." & vbCrLf & vbCrLf & _
    "Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
    Err.Clear

    End Sub


    Private Sub form_Timer()

    On Error GoTo ErrHandler

    Me.Visible = False
    Me.TimerInterval = 0

    Exit Sub

    ErrHandler:

    MsgBox "Error in Form_Timer( ) in" & vbCrLf & _
    Me.Name & " form." & vbCrLf & vbCrLf & _
    "Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
    Err.Clear

    End Sub


    Private Sub form_Unload(Cancel As Integer)

    On Error GoTo ErrHandler

    Me!EndTime.Value = Now()

    Exit Sub

    ErrHandler:

    If (Err.Number = 2448) Then
    ' Ignore, since the form is going into Design View.
    Else
    MsgBox "Error in Form_Unload( ) in" & vbCrLf & _
    Me.Name & " form." & vbCrLf & vbCrLf & _
    "Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
    End If

    Err.Clear

    End Sub
     
  2. Loading...

    Similar Threads Forum Date
    using spiritual name as a username Questions and Answers Aug 23, 2012
    General How can I change my username ? Hard Talk Sep 4, 2010
    After FIR, Social Media Users Wary of Offensive Jokes on Sardars Information Technology Oct 2, 2013
    USA US govt secretly collecting data on millions of Verizon users: Report Breaking News Jun 6, 2013
    Audience of 3 Million Users Receiving Anti-Sikh Messages Hard Talk Sep 17, 2010

  3. Douglas J Steele

    Douglas J Steele
    Expand Collapse
    Guest

    Rename your modules. Modules cannot be named the same as functions or subs
    that are contained within them.

    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no e-mails, please!)


    "ldiaz" <ldiaz@discussions.microsoft.com> wrote in message
    news:43A703FE-5DBE-42AE-A26E-9A98CA1620A3@microsoft.com...
    > Hi I'm using this code to get UserName and ComputerName of all user that
    > access to my DataBase.
    >
    > this code is in the Form, also I have two modules named: fOSMachineName

    and
    > fOSUserName , the codes of these modules wre copied from www.mvps.org but

    I
    > don't know why it does not work,
    >
    > could you help me, I will appreciate so much
    >
    > ldiaz
    >
    > ______________________________________________
    > Option Compare Database
    >
    > Private Sub form_Open(Cancel As Integer)
    >
    >
    > On Error GoTo ErrHandler
    >
    >
    > DoCmd.GoToRecord acDataForm, Me.Form, acNewRec
    >
    > Me!UserName.Text = fOSUserName()
    > Me!ComputerName.Value = fOSMachineName()
    > Me!BeginTime.Value = Now()
    > RunCommand acCmdSaveRecord
    >
    > Exit Sub
    >
    > ErrHandler:
    >
    > MsgBox "Error in Form_Open( ) in" & vbCrLf & _
    > Me.Name & " form." & vbCrLf & vbCrLf & _
    > "Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
    > Err.Clear
    >
    > End Sub
    >
    >
    > Private Sub form_Timer()
    >
    > On Error GoTo ErrHandler
    >
    > Me.Visible = False
    > Me.TimerInterval = 0
    >
    > Exit Sub
    >
    > ErrHandler:
    >
    > MsgBox "Error in Form_Timer( ) in" & vbCrLf & _
    > Me.Name & " form." & vbCrLf & vbCrLf & _
    > "Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
    > Err.Clear
    >
    > End Sub
    >
    >
    > Private Sub form_Unload(Cancel As Integer)
    >
    > On Error GoTo ErrHandler
    >
    > Me!EndTime.Value = Now()
    >
    > Exit Sub
    >
    > ErrHandler:
    >
    > If (Err.Number = 2448) Then
    > ' Ignore, since the form is going into Design View.
    > Else
    > MsgBox "Error in Form_Unload( ) in" & vbCrLf & _
    > Me.Name & " form." & vbCrLf & vbCrLf & _
    > "Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
    > End If
    >
    > Err.Clear
    >
    > End Sub
    >
     
  4. Dirk Goldgar

    Dirk Goldgar
    Expand Collapse
    Guest

    "ldiaz" <ldiaz@discussions.microsoft.com> wrote in message
    news:43A703FE-5DBE-42AE-A26E-9A98CA1620A3@microsoft.com
    > Hi I'm using this code to get UserName and ComputerName of all user
    > that access to my DataBase.
    >
    > this code is in the Form, also I have two modules named:
    > fOSMachineName and fOSUserName , the codes of these modules wre
    > copied from www.mvps.org but I don't know why it does not work,
    >
    > could you help me, I will appreciate so much
    >
    > ldiaz
    >
    > ______________________________________________
    > Option Compare Database
    >
    > Private Sub form_Open(Cancel As Integer)
    >
    >
    > On Error GoTo ErrHandler
    >
    >
    > DoCmd.GoToRecord acDataForm, Me.Form, acNewRec
    >
    > Me!UserName.Text = fOSUserName()
    > Me!ComputerName.Value = fOSMachineName()
    > Me!BeginTime.Value = Now()
    > RunCommand acCmdSaveRecord
    >
    > Exit Sub
    >
    > ErrHandler:
    >
    > MsgBox "Error in Form_Open( ) in" & vbCrLf & _
    > Me.Name & " form." & vbCrLf & vbCrLf & _
    > "Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
    > Err.Clear
    >
    > End Sub
    >
    >
    > Private Sub form_Timer()
    >
    > On Error GoTo ErrHandler
    >
    > Me.Visible = False
    > Me.TimerInterval = 0
    >
    > Exit Sub
    >
    > ErrHandler:
    >
    > MsgBox "Error in Form_Timer( ) in" & vbCrLf & _
    > Me.Name & " form." & vbCrLf & vbCrLf & _
    > "Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
    > Err.Clear
    >
    > End Sub
    >
    >
    > Private Sub form_Unload(Cancel As Integer)
    >
    > On Error GoTo ErrHandler
    >
    > Me!EndTime.Value = Now()
    >
    > Exit Sub
    >
    > ErrHandler:
    >
    > If (Err.Number = 2448) Then
    > ' Ignore, since the form is going into Design View.
    > Else
    > MsgBox "Error in Form_Unload( ) in" & vbCrLf & _
    > Me.Name & " form." & vbCrLf & vbCrLf & _
    > "Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
    > End If
    >
    > Err.Clear
    >
    > End Sub


    This line:

    > Me!UserName.Text = fOSUserName()


    should certainly be using the Value property, not the Text property:

    Me!UserName.Value = fOSUserName()

    Aside from that, I'm not sure that you'll be able to assign values to
    bound controls on the form during the form's Open event, or during the
    form's Unload event. I recall that being a problem in other situations,
    but I gather you got this code originally from Gunny ('69 Camaro), who
    is usually reliable. What error message are you getting? If you aren't
    getting an error message, in what way does it "not work"?

    --
    Dirk Goldgar, MS Access MVP
    www.datagnostics.com

    (please reply to the newsgroup)
     
  5. ldiaz

    ldiaz
    Expand Collapse
    Guest

    I have renamed the modules names to fOSMachineName1 and fOSUserName1 , also I
    have changed UserName.text to UserName.value , I got this error:

    "Error in Form_Open()in
    Error#2498
    an expression you entered is the worng data type for one of the arguments"


    I have checked step by step all my expresions and are ok.

    could you help me, I'll appreciate so much.

    God Bless.
    ldiaz


    "Dirk Goldgar" wrote:

    > "ldiaz" <ldiaz@discussions.microsoft.com> wrote in message
    > news:43A703FE-5DBE-42AE-A26E-9A98CA1620A3@microsoft.com
    > > Hi I'm using this code to get UserName and ComputerName of all user
    > > that access to my DataBase.
    > >
    > > this code is in the Form, also I have two modules named:
    > > fOSMachineName and fOSUserName , the codes of these modules wre
    > > copied from www.mvps.org but I don't know why it does not work,
    > >
    > > could you help me, I will appreciate so much
    > >
    > > ldiaz
    > >
    > > ______________________________________________
    > > Option Compare Database
    > >
    > > Private Sub form_Open(Cancel As Integer)
    > >
    > >
    > > On Error GoTo ErrHandler
    > >
    > >
    > > DoCmd.GoToRecord acDataForm, Me.Form, acNewRec
    > >
    > > Me!UserName.Text = fOSUserName()
    > > Me!ComputerName.Value = fOSMachineName()
    > > Me!BeginTime.Value = Now()
    > > RunCommand acCmdSaveRecord
    > >
    > > Exit Sub
    > >
    > > ErrHandler:
    > >
    > > MsgBox "Error in Form_Open( ) in" & vbCrLf & _
    > > Me.Name & " form." & vbCrLf & vbCrLf & _
    > > "Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
    > > Err.Clear
    > >
    > > End Sub
    > >
    > >
    > > Private Sub form_Timer()
    > >
    > > On Error GoTo ErrHandler
    > >
    > > Me.Visible = False
    > > Me.TimerInterval = 0
    > >
    > > Exit Sub
    > >
    > > ErrHandler:
    > >
    > > MsgBox "Error in Form_Timer( ) in" & vbCrLf & _
    > > Me.Name & " form." & vbCrLf & vbCrLf & _
    > > "Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
    > > Err.Clear
    > >
    > > End Sub
    > >
    > >
    > > Private Sub form_Unload(Cancel As Integer)
    > >
    > > On Error GoTo ErrHandler
    > >
    > > Me!EndTime.Value = Now()
    > >
    > > Exit Sub
    > >
    > > ErrHandler:
    > >
    > > If (Err.Number = 2448) Then
    > > ' Ignore, since the form is going into Design View.
    > > Else
    > > MsgBox "Error in Form_Unload( ) in" & vbCrLf & _
    > > Me.Name & " form." & vbCrLf & vbCrLf & _
    > > "Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
    > > End If
    > >
    > > Err.Clear
    > >
    > > End Sub

    >
    > This line:
    >
    > > Me!UserName.Text = fOSUserName()

    >
    > should certainly be using the Value property, not the Text property:
    >
    > Me!UserName.Value = fOSUserName()
    >
    > Aside from that, I'm not sure that you'll be able to assign values to
    > bound controls on the form during the form's Open event, or during the
    > form's Unload event. I recall that being a problem in other situations,
    > but I gather you got this code originally from Gunny ('69 Camaro), who
    > is usually reliable. What error message are you getting? If you aren't
    > getting an error message, in what way does it "not work"?
    >
    > --
    > Dirk Goldgar, MS Access MVP
    > www.datagnostics.com
    >
    > (please reply to the newsgroup)
    >
    >
    >
     

Share This Page