Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with table row level security

Status
Not open for further replies.

rvmams

Technical User
Jan 28, 2003
22
0
0
GB
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!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top