User access levels using VB

kirtney

Registered User.
Local time
Yesterday, 17:51
Joined
May 26, 2011
Messages
14
Hi I am trying to create a password enabled database for multiple users. I was looking online and i found a way to do it but when i use the VB code that they have outlined but i keep getting this error when i run the command compile error syntax error. So i was wondering if someone can look at my visual basic scripting and tell me what i have done wrong. Thanks very Much

On Error GoTo errline
If IsNull(Me.txtUserName) Then
MsgBox “Please enter a User Name.”, vbInformation, “Missing User Name”
Exit Sub
End If

If IsNull(Me.txtPassword) Then
MsgBox “Please enter a Password for the user name ” & Me.txtUserName & “.”, vbInformation, “Missing User Name”
Exit Sub
End If

Dim rs As DAO.Recordset

Set rs = CurrentDb.OpenRecordset(“qryRS”)
With rs
If .EOF And .BOF Then
MsgBox “Your log on information was incorrect. Try again.”, vbCritical, “Failed Log On”
GoTo exitline
Else
If !Administrator_Rights = False Then
DoCmd.OpenForm “frmMenu”
DoCmd.Close acForm, “frmLogOn”
GoTo exitline
End If
End If
End With

If chbxEditTable = -1 Then
DoCmd.OpenTable “tblUsers”, acViewNormal
DoCmd.Close acForm, “frmLogOn”
Else
DoCmd.OpenForm “frmMenu”
DoCmd.Close acForm, “frmLogOn”
End If

exitline:
If Not rs Is Nothing Then
rs.Close
Set rs = Nothing
End If

Exit Sub
errline:

Select Case Err.Number
Case Else
MsgBox “There was an error in the program. Please notify database administrator of the following error: Error Number: ” & Err.Number & “ ” & Err.Description, vbCritical, “Please write this error down and note what you were doing at the time.”

GoTo exitline
End Select
 
Have you thought about using the user level security wizard that comes with Access? It'd be much more secure than this - as it stands a user could just ctrl-break out of the code at any time and get into the back end of the DB....
 
Simply Login into a database through a login form not at all serves the purpose of database or objects' security. I don't want to comment on this code.

I copied the code into a module to have a look at it. All the MsgBox lines highlighted indicating Syntax Error on those lines. The MsgBox Syntax looks perfectly alright, but there is some invisible problem in those lines (the code image is attached).

Re-write all MsgBox lines manually and retry. You can disable the On Error Goto Errline temporarily that will help to stop the program on the Error line in Debug Mode.

Microsoft Access Security
 

Attachments

  • Error.jpg
    Error.jpg
    83.1 KB · Views: 154

Users who are viewing this thread

Back
Top Bottom