Hi,
I want to implement table row level security for my database. I followed faq 181 641. But now I am stuck. I amended my SQL statement to the following:
SELECT [Time Cards].[TimeCardID], [Time Cards].[EmployeeID], [Time Cards].[DateEntered] FROM [Time Cards] WHERE [EmployeeID]=^_^;
The field employee ID is a numeric field.
The code I have put in is:
Private Sub Form_Open(Cancel As Integer)
Const ReplString = "+999"
Dim intInsPt As Integer, strUserMatch As Variant
intInsPt = InStr(Me.RecordSource, ReplString)
If intInsPt = 0 Then
' Oops! SQL template has no ReplString in it!
Beep
MsgBox "Form Record Source error. Notify programmer.", vbExclamation
Cancel = True
Exit Sub
End If
strUserMatch = DLookup("EmployeeID", _
"UserInfo", "UserName='" & CurrentUser() & "'"
If IsNull(strUserMatch) Then
' Oops! No match for user in UserInfo table
Beep
MsgBox "No permission found for " & CurrentUser() _
& ". Notify programmer.", vbExclamation
Cancel = True
Exit Sub
End If
' Now modify the form record source to select
' records for this user only
Me.RecordSource = Left$(Me.RecordSource, intInsPt - 1) _
& strUserMatch _
& Mid$(Me.RecordSource, intInsPt + Len(ReplString))
End Sub
And now I am getting error 3075 saying that it is missing an operator.
Can anyone help.... I am Stuck!!!
I want to implement table row level security for my database. I followed faq 181 641. But now I am stuck. I amended my SQL statement to the following:
SELECT [Time Cards].[TimeCardID], [Time Cards].[EmployeeID], [Time Cards].[DateEntered] FROM [Time Cards] WHERE [EmployeeID]=^_^;
The field employee ID is a numeric field.
The code I have put in is:
Private Sub Form_Open(Cancel As Integer)
Const ReplString = "+999"
Dim intInsPt As Integer, strUserMatch As Variant
intInsPt = InStr(Me.RecordSource, ReplString)
If intInsPt = 0 Then
' Oops! SQL template has no ReplString in it!
Beep
MsgBox "Form Record Source error. Notify programmer.", vbExclamation
Cancel = True
Exit Sub
End If
strUserMatch = DLookup("EmployeeID", _
"UserInfo", "UserName='" & CurrentUser() & "'"
If IsNull(strUserMatch) Then
' Oops! No match for user in UserInfo table
Beep
MsgBox "No permission found for " & CurrentUser() _
& ". Notify programmer.", vbExclamation
Cancel = True
Exit Sub
End If
' Now modify the form record source to select
' records for this user only
Me.RecordSource = Left$(Me.RecordSource, intInsPt - 1) _
& strUserMatch _
& Mid$(Me.RecordSource, intInsPt + Len(ReplString))
End Sub
And now I am getting error 3075 saying that it is missing an operator.
Can anyone help.... I am Stuck!!!