Reports with filters

csdrex87

Registered User.
Local time
Today, 08:58
Joined
Jul 1, 2009
Messages
66
Hey,

So i looked up some other threads on getting filters on reports pre-emptively before you actually open the report. What I am trying to do is take my ULS which contains the last name and the access level and look up the user ID number (which is displayed in the employeeinformation table) and create a filter for the current user.

The error im gettins is that "The expression you entered as a query parameter produced this error: 'Shmoe'" (which is the users last name)

This is my code if anyone can help make sense of this error with me

Case 1

strUN = Forms!formUserLoginAccess!txtUN
intID = DLookup("[Emp_ID]", "tblEmployeeInformation", "[Emp_Lname]=" & strUN)

intUSL = Forms!formUserLoginAccess!txtUSL

strReport = InputBox("Please Enter the Name of the report you wish to view i.e. DailyReport, WeeklyReport, ForecastReport")

If intUSL = 1 Then
DoCmd.OpenReport strReport, acViewNormal
End If

If intUSL = 2 Then
DoCmd.OpenReport strReport, acViewNormal, , "[Emp_ID]=" & intID
End If

If intUSL = 3 Then
DoCmd.OpenReport strReport, acViewNormal, , "[Emp_ID]=" & intID
End If
If intUSL = 4 Then If MsgBox("You do not have sufficient access to this database!", vbOKOnly, "Restricted Access") = vbOK Then DoCmd.Quit
 
Try this:

intID = DLookup("[Emp_ID]", "tblEmployeeInformation", "[Emp_Lname]='" & strUN & "'")
 
That worked well. Although i guess i have the wrong command? It keeps trying to print that report to the default printer. What is the command to view it in access?
 
Change acViewNormal to acViewPreview
 

Users who are viewing this thread

Back
Top Bottom