Error 3167 "Record is Deleted"

R

Rosco

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
 
T

Tony Toews

Rosco said:
I have the following code in a function to output a report to a snap file. I
get the above error.

This message is a sign of corruption.

For more information on corruption including possible causes,
determining the offending PC, retrieving your data, links, official MS
KB articles and a list of vendors who state they can fix corruption
see the Microsoft Access Corruption FAQ at
http://www.granite.ab.ca/access/corruptmdbs.htm

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top