I have a report (based on a query which has one parameter (Date)) stored in Access
I have code that will print the report directly from VB6
I am trying to get the report to print and pass the date parameter in code but I still keep getting the parameter box prompt.
Here is the code:
Code:'Call the procedure PrintEndOfDayReport "DOS= " & Format$(DTPicker1, "dd/MMM/yy") Private Sub PrintEndOfDayReport(strParam As String) Dim dbName As String Dim rptName As String Dim Preview As Long Const acNormal = 0 Const acPreview = 2 On Error GoTo ErrorTrap Set objAccess = New Access.Application 'Set the path to the database dbName = App.Path & "\Customers.mdb" rptName = "rptEndOfDay" Preview = acNormal 'acPreview will show a print preview and open up the db With objAccess 'open the db .OpenCurrentDatabase filepath:=dbName If Preview = acPreview Then .Visible = True .DoCmd.OpenReport rptName, Preview Else .DoCmd.OpenReport rptName, , strParam End If End With Set objAccess = Nothing Exit Sub ErrorTrap: MsgBox "An error has occurred in the procedure PrintEndOfDayReport!" _ & vbNewLine & "The error number is: " & Err.Number _ & vbNewLine & "The error description is: " & Err.Description End Sub


Reply With Quote