
Error msg: Object variable or With block variable not set
Error msg: Object variable or With block variable not set
Does anyone know what this error is coming from? The help file is not too
helpful. The error occurs in the following Sub routine between the two
asterisked lines. The query does exist and works. I am using recordsets
through out my module, the only difference is that the is the first time I
used a query and used a query with such a long name. What I did get from the
help file is that it is permitted to use queries for a RecordSet.
TIA
Scott
'------------------------------------------------------------------
' Exportdata()
' Create the text output export file
'------------------------------------------------------------------
Public Sub Exportdata()
On Error GoTo exportdata_Err
Dim pvNewFileName As String
Dim db As Database
Dim pvrst As DAO.Recordset
DoCmd.SetWarnings False
;********************************************************
Set pvrst = db.OpenRecordset("tblMain Without Matching tblRetail_Cost")
;********************************************************
If pvrst.EOF Then
'spacer
Else
sendemail 'some external sub routine
DoCmd.TransferSpreadsheet acExport, 8, "tblMain Without Matching
tblRetail_Cost", "Missing Retail_Cost Adjustments", True, ""
CloseApp 'some external sub routine
End If
pvNewFileName = OutputFilename 'some external sub routine
'DoCmd.TransferText acExportDelim, "ExportNonPromo", "qryExportOutput",
gvMaindir & "\output\" & pvNewFileName & ".txt", True, ""
DoCmd.TransferText acExportDelim, "ExportNonPromo", "Output", gvMaindir &
"\output\" & pvNewFileName & ".txt", True, ""
DoCmd.SetWarnings True
exportdata_Exit:
Exit Sub
exportdata_Err:
sendemail 'some external sub routine
CloseApp 'some external sub routine
End Sub 'Exportdata()