applyfilter question (1 Viewer)

swarv

Registered User.
Local time
Today, 22:34
Joined
Dec 2, 2008
Messages
196
Hi all,

I have this:

Code:
Private Sub Report_Load()
Dim s As String
Dim str As String
s = InputBox("Enter the dept", vbOKCancel)
str = "dept = " & s
DoCmd.ApplyFilter , str
End Sub

It asks me twice for a value.
All I want to do is enter a dept and then the report show with the filter as for example:
dept = art
where art is s for example.

im sure theres something im missing here

thanks

Martin
:confused:
 

apr pillai

AWF VIP
Local time
Tomorrow, 03:04
Joined
Jan 20, 2005
Messages
735
Try the following Code after changing the line: Reports!ReportName with your Report Name:

Code:
Private Sub Report_Open(Cancel As Integer)
Dim str As String, Rpt As Report, s As String

s = InputBox("Enter the dept", "Filter Criteria")

Set Rpt = Reports!ReportName
str = "Dept = " & Chr$(34) & s & Chr$(34)
Rpt.Filter = str
Rpt.FilterOn = True

End Sub
 

Users who are viewing this thread

Top Bottom