Greetings All:
I am trying to export a comma delim file from a query but keep getting a 3011 Error "could not find the object 'SELECT * FRom LarqData WHERE Date_Time > 12:00:00AM'.
Code:
Sub SerialExport()
Dim strGetLastDateSQL, strGetDailyRecsSQL, strInsExpDateSQL As String
Dim strFileName As String
Dim dteLastExp As Date
Dim dteTodayDate As String
Dim oApp As New Outlook.Application
Dim oEmail As Outlook.MailItem
dteTodayDate = Format(Date, "MMDDYYYY")
strFileName = "C:\Users\davei\Desktop\Database\LarqSerialExport_" & dteTodayDate
strGetLastDateSQL = "SELECT Max(LastExport) As dteLastExp FROM ExpTracking"
strGetDailyRecsSQL = "SELECT * FROM LarqData WHERE Date_Time >" & dteLastExp
strInsExpDateSQL = "INSERT INTO ExpTracking (LastExport)#" & Now() & "#)"""
DoCmd.SetWarnings False
DoCmd.TransferText acExportDelim, "", strGetDailyRecsSQL, strFileName, False, ""
CurrentDb.Execute strInsExpDateSQL
CurrentDb.Execute strInsExpDateSQL
DoCmd.SetWarnings True
End Sub
Will I need to query into an empty table, and then use the TransferText function? I am at a loss here. Any assistance would be greatly appreciated.