Hello guys.So I have this code, which is executed on load on my main form when user opens database.
It looks up in the table "Korisnici" (Users), and if the username is not found it closes the database.
The database file is on the company server. This code meant to protect the database from unathorized access,but it won't load due to security warning, until user clicks "Enable content" on his computer.
Up until then user is free to do whatever he wants and I want to stop that.
Do you have an idea what can I do?
Here is the code below.
Code:
Option Compare Database
Private Sub Form_Load()
Username = fOSUserName()
Set dbs = CurrentDb()
strSQL = "SELECT access_level FROM Korisnici WHERE Username = '" & Username & "';"
Set rst = dbs.OpenRecordset(strSQL)
If rst.RecordCount = 0 Then
strMsg = Username &", nemate pristup bazi podataka!"
MsgBox strMsg
DoCmd.closeDatabase
Return
End if
access_level = rst![access_level]
rst.Close
dbs.Close
If access_level < 5 Then
DoCmd.NavigateTo "acNavigationCategoryObjectType"
DoCmd.RunCommand acCmdWindowHide
DoCmd.ShowToolbar "Ribbon", acToolbarNo
Else
DoCmd.SelectObject acTable, , True
DoCmd.ShowToolbar "Ribbon", acToolbarYes
End If
End Sub