Need help with Dlookup function for use to secure forms

D

David

I am useing Win XP and Access 2003.

I have a table called tblAdmins with the users that have full access.
Another table called tblTeamLeads who have some access and then users who can
log data only.

I am using the Dlookup function in conjunction with a feature that gets the
users Windows Login ID. I have the WinIds in the respective tables.

So with that here is the code that I am using:
Private Sub TeamLead_Click()
On Error GoTo Err_TeamLead_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim varUser As Variant
Dim varX As Variant, varXx As Variant
varUser = Get_User_Name()
varX = DLookup("[userid]", "tblAdmins", "userid = " & varUser)

varXx = DLookup(varUser, "tblTeamLeads")

If varUser = varX Or varUser = varXx Then
stDocName = "Team Lead Page"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Else
MsgBox ("You are not Authorized to access this page.")
Exit Sub
End If
Exit_TeamLead_Click:
Exit Sub

Err_TeamLead_Click:
MsgBox Err.Description
Resume Exit_TeamLead_Click

End Sub
***************

I keep getting an error of "The expression you entered as a query parameter
produced this error: 'David'"

where David is my windows Id for this example.
 
J

Joan Wild

varX = DLookup("[userid]", "tblAdmins", "userid = '" & varUser & "'")

However, you might think about using just a single table with
WinIds, MemberOf then just match the login name to see which group they
are in.

Joan Wild
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top