G
Guest
I have the following code in a function to output a report to a snap file. I
get the above error. When I click debug it highlights the OutputTo statement.
Sometimes it will let me force completion of the code, other times Ill get
"OutpuTo not available" error. I've used this in multiple apps without
problem. All variables are holding their values, I just cn't see what
records it is even looking for. I just can not figure out where my errors is.
Thanks in advance for any insight and help.
-Rosco
Code follows:
Function OutputReport()
Dim strReportName As String, strPath As String, strFileName As String
Call ReportQuery
'On Error GoTo OUTPUT_ERROR
strOutputFormat = "Snapshot Format"
strReportName = "rptStrOrderRpt"
strPath = "\\ServerName\ShareName\Folder\"
strFileName = strSelectedVendNme & " " & varSelectedStrNbr & " Order
Report " & Format(Date, "yyyy-mm-dd") & ".snp"
'Debug.Print strReportName
'Debug.Print strPath
'Debug.Print strFileName
'export report as a snap file >>>> This is where the debugger says the
problem lies.
If Len(strPath) > 0 Then
DoCmd.OutputTo acOutputReport, _
strReportName, acFormatSNP, strPath & strFileName
Else
MsgBox "Specified path does not exist. Check that path and folder
name are correct.", vbCritical + vbOKOnly, "PDF Error"
Exit Function
End If
FINISH:
Call ClearVariables
Call ClearRptVariables
Exit Function
OUTPUT_ERROR:
MsgBox "An Error occurred while creating the output file. The output
file was not created.", vbCritical + vbOKOnly, "Output Error!"
GoTo FINISH
End Function
Function ReportQuery() <<< This works Fine - Here for reference>>>
Dim sqlString As String, sqlWhere As String
Dim db As Database, qd As QueryDef
varSelectedRevDte = Date
sqlWhere = "WHERE" & "(REV_DTE IN(#" & varSelectedRevDte & "#,)) AND
(STR_NBR IN(" & varSelectedStrNbr & ")) AND (VEND_NBR IN(" &
varSelectedVendNbr & "))"
sqlString = "SELECT [str_nbr] & '_' & [vend_nbr] & '_' & [rev_dte] AS
VENDKEY, "
sqlString = Big long string statement
'check for existing query and delete it, prior to recreating
Call ChkQueryExists
'Debug.Print sqlString
Set db = CurrentDb
'build the query
With db
Set qd = db.CreateQueryDef("qryOrderReport", sqlString)
End With
sqlString = ""
sqlWhere = ""
Set qd = Nothing
Set db = Nothing
End Function
get the above error. When I click debug it highlights the OutputTo statement.
Sometimes it will let me force completion of the code, other times Ill get
"OutpuTo not available" error. I've used this in multiple apps without
problem. All variables are holding their values, I just cn't see what
records it is even looking for. I just can not figure out where my errors is.
Thanks in advance for any insight and help.
-Rosco
Code follows:
Function OutputReport()
Dim strReportName As String, strPath As String, strFileName As String
Call ReportQuery
'On Error GoTo OUTPUT_ERROR
strOutputFormat = "Snapshot Format"
strReportName = "rptStrOrderRpt"
strPath = "\\ServerName\ShareName\Folder\"
strFileName = strSelectedVendNme & " " & varSelectedStrNbr & " Order
Report " & Format(Date, "yyyy-mm-dd") & ".snp"
'Debug.Print strReportName
'Debug.Print strPath
'Debug.Print strFileName
'export report as a snap file >>>> This is where the debugger says the
problem lies.
If Len(strPath) > 0 Then
DoCmd.OutputTo acOutputReport, _
strReportName, acFormatSNP, strPath & strFileName
Else
MsgBox "Specified path does not exist. Check that path and folder
name are correct.", vbCritical + vbOKOnly, "PDF Error"
Exit Function
End If
FINISH:
Call ClearVariables
Call ClearRptVariables
Exit Function
OUTPUT_ERROR:
MsgBox "An Error occurred while creating the output file. The output
file was not created.", vbCritical + vbOKOnly, "Output Error!"
GoTo FINISH
End Function
Function ReportQuery() <<< This works Fine - Here for reference>>>
Dim sqlString As String, sqlWhere As String
Dim db As Database, qd As QueryDef
varSelectedRevDte = Date
sqlWhere = "WHERE" & "(REV_DTE IN(#" & varSelectedRevDte & "#,)) AND
(STR_NBR IN(" & varSelectedStrNbr & ")) AND (VEND_NBR IN(" &
varSelectedVendNbr & "))"
sqlString = "SELECT [str_nbr] & '_' & [vend_nbr] & '_' & [rev_dte] AS
VENDKEY, "
sqlString = Big long string statement
'check for existing query and delete it, prior to recreating
Call ChkQueryExists
'Debug.Print sqlString
Set db = CurrentDb
'build the query
With db
Set qd = db.CreateQueryDef("qryOrderReport", sqlString)
End With
sqlString = ""
sqlWhere = ""
Set qd = Nothing
Set db = Nothing
End Function