I'm trying to automate the export of some queries, but for some reason I'm getting an error message half-way through. The first two queries export perfectly fine, but then I start getting a "Run-time error 3011" for all of the other queries.
Any ideas why this might be?
Code:
Dim timeStamp As String
timeStamp = Format(Now(), "mmddyyhh")
If Me.txtExportPath.Value = "" Then
MsgBox "Export path not found"
Exit Sub
End If
path = Me.txtExportPath.Value
DoCmd.TransferText acExportDelim, "SpecExport", "Report1", path & "\Report1_" & timeStamp & ".txt", True
DoCmd.TransferText acExportDelim, "SpecExport", "Report2", path & "\Report2_" & timeStamp & ".txt", True
'Process fails with Reports 3 and 4.
DoCmd.TransferText acExportDelim, "SpecExport", "Report3", path & "\Report3_" & timeStamp & ".txt", True
DoCmd.TransferText acExportDelim, "SpecExport", "Report4", path & "\Report4_" & timeStamp & ".txt", True