Share via

ACCESS LOGIN FORM

Anonymous
2015-12-29T16:09:15+00:00

hi please advise to how to make the form as read only format for below code.

Private Sub Command1_Click() Dim UserLevel As Integer If IsNull(Me.txtLoginID) Then MsgBox "Please enter LoginID", vbInformation, "LoginID Required" Me.txtLoginID.SetFocus ElseIf IsNull(Me.txtPassword) Then MsgBox "Please enter password", vbInformation, "Password Required" Me.txtPassword.SetFocus Else 'process the job If (IsNull(DLookup("UserLogin", "tblUser", "UserLogin ='" & Me.txtLoginID.Value & "'"))) Or _ (IsNull(DLookup("password", "tblUser", "Password ='" & Me.txtPassword.Value & "'"))) Then MsgBox "Incorrect LoginID or Password" Else UserLevel = DLookup("UserSecurity", "tblUser", "UserLogin = '" & Me.txtLoginID.Value & "'") DoCmd.Close If UserLevel = 1 Then 'MsgBox "LoginID and Password correct" DoCmd.OpenForm "Navigation Form" Else If UserLevel = 2 Then (I need to make the user level 2 as read only) 'MsgBox "LoginID and Password correct" DoCmd.OpenForm "Security_DS" End If End If End If End If End Sub

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. ScottGem 68,830 Reputation points Volunteer Moderator
    2015-12-29T17:42:46+00:00

    Please review my blog on Login Security using VBA. it discusses such things.

    Was this answer helpful?

    0 comments No comments
  2. Tom van Stiphout 40,211 Reputation points MVP Volunteer Moderator
    2015-12-29T16:39:13+00:00

    I would store UserLevel in a global variable. Then in the Form_Open event:

    if UserLevel = 2 then

      Me.AllowEdits = False

      'Also consider AllowDeletions and AllowAdditions

    end if

    Was this answer helpful?

    0 comments No comments