Logon Start and End Date/Time Stamp

Bobby1st

Registered User.
Local time
, 21:32
Joined
Jan 5, 2007
Messages
62
I have an issue and I tried every trick I could find and I need help from the expert. I got the idea on one of the thread but I have to revised to fit my database, however, I have a problem keepping the Users Information to memory and use it to stamp the date/time on exit. I tried to use the Static statement but failed. Attached is my codes.

MODULE SETUP

Public Type UserInfo
ID As Integer
PASS As String
End Type

Public User2 As UserInfo
========================================
LOGON FORM ‘[ Textboxes on Logon form: UserId and Password textbox] [ This one works but won’t keep User 2 UserInfo in memory]

Public Sub Command0_Click()
Dim rst As Recordset
Dim db As Database
Dim ID, Level
Dim Password2, PASS4

On Error GoTo errorhandler
'[ On Error Resume Next]

ID = UserID.Value <from textbox >
Set db = CurrentDb
‘[ TblAdminCurrMnth contains ID, PASS, Level (access level) fields ]
Set rst = db.OpenRecordset("SELECT * FROM [tblAdminCurrMnth] WHERE [ID]= " & ID)

PASS4 = rst(1).Value
Level = rst(2).Value

If IsNull(Password) Then <from textbox on sign-on>
MsgBox "Invalid password, try again."
Exit Sub
ElseIf Password.Value <> PASS4 Then
MsgBox "Invalid password, try again."
UserID.Value = "xxxxxxxx"
Password.Value = "xxxxxxxx"
DoCmd.GoToControl ("UserID")
Exit Sub
EndIf Level < 4 Then 'Admin >=6
MsgBox "Not Authorized", vbCritical, "Entry Denied"
DoCmd.Close acForm, "frmMainGate"
rst.Close
Exit Sub
Else
DoCmd.OpenForm "frmStartup"
End If
End If
End If


With User2 < I work around this one to work >
.ID = UserID.Value
.PASS = PASS4
End With
'rst.Close

errorhandler:
Select Case Err.Number
Case 3021
MsgBox ("Invalid login" _
& " Please try again")
UserID.Value = "oooooo"
Password.Value = "oooooo"
DoCmd.GoToControl ("UserId")
End Select
====================================

START UP ‘[ I copied this idea from this forum, This one works ]
<This stamp the start time>

Private Sub Form_Timer()
On Error GoTo Err_Form_Timer

Dim dbs As DAO.Database
Dim rst As DAO.Recordset

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("ztblUserLog", dbOpenDynaset)

With rst
.AddNew
![PASS] = User2.PASS
.Update
End With
'MsgBox MyPass

DoCmd.Close acForm, "frmMainGate"
DoCmd.Close acForm, "frmStartup"
DoCmd.OpenForm "switchboard"
'Forms!switchboard.Visible = False

Exit_Form_Timer:
Exit Sub

Err_Form_Timer:
MsgBox Err.Description
Resume Exit_Form_Timer
End Sub
======================================== ON EXIT
SWITCHBOARD
‘[ I uses the Switchboard and inserted this line ]

Case conCmdExitApplication
If rst(0) = 1 And rst(1) = 5 Then ‘<This execute when Exit button is select from the menu items >

DoCmd.OpenForm "frmStartDn" ‘[this is similar to the Start Up, it will run to stamp the end time but not working][There might be a better way?]

End If
'CloseCurrentDatabase


==========================================
START_DN_ FORM <frmStartDn >

< This does not work to stamp the end time >

Private Sub Form_Timer()
On Error GoTo Err_Form_Timer
Dim intResponse As Integer
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim Pass3, ID

ID = User2.ID <THIS IS MY PROBLEM, VARIABLE IS EMPTY >
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT * FROM [ztblUserLog] WHERE [LogID]= " & ID)
Pass3 = rst(2).Value

'With rst
'.FindLast <THIS ONE FAILED > ======================
'![PASS] = Pass3
'.Edit
'.Update
' End With


DoCmd.Close acForm, "frmStartDn"
CloseCurrentDatabase
'DoCmd.OpenForm "switchboard"
'Forms!switchboard.Visible = False

Exit_Form_Timer:
Exit Sub

Err_Form_Timer:
MsgBox Err.Description
Resume Exit_Form_Timer
End Sub
 

Users who are viewing this thread

Back
Top Bottom