I have split my db and distributed the FE to client pcs while BE is on the network. To demonstrate it i have 2 users , userA who has read/write rights on the shared folder where BE is while userB only has read rights on the shared BE folder. When userA opens the FE he can get in(writing userinfo in the table on the OnLoad event) but when userB gets in the FE opens fine EXCEPT he gets the error that there was an error on the OnLoad event, which i am fine with because userB doesnt have right access to the db yet. But now if the FE is closed by both users and this time when userB logs(read rights only) in before userA(read/write rights) he gets in with no error on the onLoad event but now if userA logs in he is shown the same error on the onLoad event!!!
i am totally lost as to what i have missed, can someome help? this is my code on the onLoad event in the FE:
i am totally lost as to what i have missed, can someome help? this is my code on the onLoad event in the FE:
Code:
Private Sub Form_Load()
On Error GoTo formload_errhandler
Me.InsideHeight = 5000
Me.InsideWidth = 10000
DoCmd.Maximize
Me.picBox.Height = Me.InsideHeight
'authenticate the logged user
Dim userName As String
userName = Environ("Username")
'check to see if username is in the SECURITY table
Dim objRS As ADODB.Recordset
Set objRS = New ADODB.Recordset
With objRS
.CursorLocation = adUseClient
.CursorType = adOpenKeyset
.Open "SELECT * FROM USER_SECURITY WHERE userID='" & userName & "'", CurrentProject.Connection
.ActiveConnection = Nothing
End With
If objRS.EOF Then
MsgBox (userName & ", access denied")
userAuthenticated = False
DoCmd.Quit
Else
userAuthenticated = True
End If
'at this point userAuthenticated is true
'log the user in USER_LOG table updating userID,dateEntered fields
Dim objCommand As ADODB.Command
Set objCommand = New ADODB.Command
Dim strSQL As String
strSQL = "INSERT INTO USER_LOG (userID,dateEntered) VALUES" & _
"('" & Environ("Username") & "',#" & Now() & "#)"
'save userEntered so userExit can be updated to the right record
'this will be used to query the right record when the user exits
dateEntered = Now()
Set objCommand.ActiveConnection = CurrentProject.Connection
objCommand.CommandText = strSQL
objCommand.Execute
Set objCommand = Nothing
formload_errhandler:
MsgBox ("Application has encountered an expected error")
Resume Next
End Sub