-
How could I pass parameters to an Access report, so it uses them as filters for the query/table in which is based?
I have an Access report which lists records containing a Date/Time column. How could I filter that report from VB, so it only shows the period of time I want?
Thanks in advance.
-
I never used reports in Access so I don't know what I'm talking about! :)
Anyway...
What you could do is have a table with a field on it into which you can insert (from VB) a filter string.
Then, alter you report or whatever to read the filter string from the table instead of from a parameter.
Hmmm... that almost sounded as though I knew what I was talking about.
-
I've done this thing before, its fairly simple.
In this example my report was just based on a parameter query with recnum being its parameter. The report just gave me info about a particular record.
I belive the AcViewNormal causes the report to print.
there are parameters that allow you to preview it first.
This should give you the basics do help in access on openreport and it should giveyou the info you need.
Private Sub PrintLog_Click()
On Error GoTo exit_sub
Screen.MousePointer = vbHourglass
Dim objAccess As Object
Set objAccess = GetObject(probdb, "Access.Application")
objAccess.DoCmd.OpenReport "Problems", acViewNormal, , "[recnum] = " & RecNum
Set objAccess = Nothing 'end the OLE Automation session
Screen.MousePointer = vbDefault
Exit Sub
exit_sub:
Set objAccess = Nothing
Call app_err(Err.Number, Err.Description, Me.Caption)
Screen.MousePointer = vbDefault
End Sub