Save Password Possible??

fenhow

Registered User.
Local time
Yesterday, 19:53
Joined
Jul 21, 2004
Messages
599
Hello,

I am using this code I found on this forum quite some time ago. It has served me well.

I was wondering if there was some easy way to add a check box that would allow a user to "Save" their username and password so they do not have to plug it in each time they go into the DB.

This code is in a Module.

Thanks. Fen How

Option Compare Database
Option Explicit

Public Type UserInfo

UserID As String
UserName As String
UserPassword As String
UserLevel As Integer

End Type
Public User As UserInfo

Function LogUserOff()
On Error GoTo Err_LogUserOff
'Requires the reference to Microsoft DAO 3.6 Object Library to be set.

Dim db As DAO.Database
Dim rst As DAO.Recordset

Set db = CurrentDb()
Set rst = db.OpenRecordset("tblLogTimes", dbOpenDynaset)

rst.FindLast "UserID = " & User.UserID
rst.Edit
rst!LoggedOut = Now()
rst.Update

User.UserLevel = 0

Exit_LogUserOff:
Exit Function

Err_LogUserOff:
Resume Exit_LogUserOff

End Function

Function LogUserOn()
On Error GoTo Err_LogUserOn

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

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

With rst
.AddNew
![UserID] = User.UserID
.Update
End With

Exit_LogUserOn:
Exit Function

Err_LogUserOn:
Resume Exit_LogUserOn

End Function

Function IsLoaded(ByVal strFormName As String) As Boolean

Const conObjStateClosed = 0
Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If

End Function

Function SetProps(ByVal strForm As String)

With Forms(strForm)

Select Case User.UserLevel

Case 1 'Admin Permissions


Case 2 'Manager Permissions


Case 3 'User Permissions


Case 4 'Guest Permissions


Case Else 'No UserLevel set

DoCmd.Close acForm, strForm

End Select

End With



End Function
 
Why write in security and then write in a way to bypass the security?
Just don't require them to log in.
Also, starting in Access 2000, I think, you can determine if a form is open like this...
Code:
CurrentProject.AllForms("YourFormName").IsLoaded
 

Users who are viewing this thread

Back
Top Bottom