Results 1 to 6 of 6
  1. #1
    ChobeyGuddu is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2016
    Posts
    29

    Logon/Logoff Tracking

    HI All,


    the code below works fine with access 2010 version (Local machine) but we have a network drive (Company share drive) which is on Access 2003 and the same code doesnt work on that version

    Can you pls help me with the Logon/Logoff tracking code for 2003 version.



    Globals Module :
    Option Compare Database
    Option Explicit
    Public Sub Logging(Activity As String)
    CurrentDb.Execute "INSERT INTO tbl9ActivityLog (UserName, Activity) Values('" & TempVars("UserName").Value & "', '" & Activity & "')"
    End Sub


    LOGIN FORM CODE :
    Option Compare Database
    Option Explicit
    Private Sub btnLogin_Click()
    Dim rs As Recordset
    Set rs = CurrentDb.OpenRecordset("tbl1Employees", dbOpenSnapshot, dbReadOnly)
    rs.FindFirst "UserName='" & Me.txtUserName & "'"
    If rs.NoMatch Then
    Me.lblWrongUser.Visible = True
    Me.txtUserName.SetFocus
    Exit Sub
    End If
    Me.lblWrongUser.Visible = False

    TempVars("UserName").Value = Me.txtUserName.Value

    If rs!Password <> Nz(Me.txtPassword, "") Then
    Me.lblWrongPass.Visible = True
    Me.txtPassword.SetFocus
    Exit Sub
    End If
    Me.lblWrongPass.Visible = False
    Me.Visible = False
    Globals.Logging "Logon"

    DoCmd.OpenForm "Menu_Selection"
    ' DoCmd.Close acForm, Me.Name
    End Sub
    -----------------
    Private Sub Form_Unload(Cancel As Integer)
    Globals.Logging "Log-off"
    End Sub


    Thanks
    Guddu

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    tempvars were not implemented until 2007, so a 2003 will not recognise them. Instead use global variables

  3. #3
    Micron is online now Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Or use the Environ function, or get a copy of fOsUsername (Google). I prefer the latter.
    I see no need for allowing for both, but we're all probably going to be seeing more multi-routine code to permit different user environments, like when using 64 bit versions of Office. So if you ever need to, you can test for db version and set up environment variables accordingly.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    ChobeyGuddu is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2016
    Posts
    29
    Quote Originally Posted by Ajax View Post
    tempvars were not implemented until 2007, so a 2003 will not recognise them. Instead use global variables
    Thanks Ajax
    Sorted with Environ

    Cheers
    Guddu.

  5. #5
    ChobeyGuddu is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2016
    Posts
    29
    Thanks Micron,
    for your valuable suggestions...


    I will learn about fOsUsername later somepoint.. but Environ did worked for me for now..

    Cheers
    Guddu.

  6. #6
    Micron is online now Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Glad to have helped. After reading my post again I think I should clarify that by "both" I meant one of my suggestions and tempvars.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Need help with VB Logon Screen
    By tmb842 in forum Access
    Replies: 6
    Last Post: 12-27-2016, 06:16 AM
  2. logon
    By slimjen in forum Forms
    Replies: 1
    Last Post: 10-06-2011, 02:51 PM
  3. Users logon and permissions
    By eman in forum Programming
    Replies: 10
    Last Post: 10-03-2011, 11:10 PM
  4. Logon form
    By Andyjones in forum Forms
    Replies: 5
    Last Post: 09-13-2011, 01:58 PM
  5. XP Logon type form
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-31-2010, 02:00 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums