lookforsmt
Registered User.
- Local time
- Tomorrow, 01:02
- Joined
- Dec 26, 2011
- Messages
- 672
Hi! All
I am trying to create a Temp Table based on date prompt (busStartDate & busEndDate) using something similar vba code
Currently the below code is to export data into excel, while i am looking to create Table in the same db
My table to be created is TempError from tbl_DispatchDetails and query name is qryDataToSend which has date prompt on it
Request guidance on how to re-write this code for creating table
Thank you
I am trying to create a Temp Table based on date prompt (busStartDate & busEndDate) using something similar vba code
Currently the below code is to export data into excel, while i am looking to create Table in the same db
My table to be created is TempError from tbl_DispatchDetails and query name is qryDataToSend which has date prompt on it
Code:
Private Sub Command0_Click()
Dim busStartDate As Date
Dim busEndDate As Date
Const xlsFileName = "C\Tempfile\MyExcelExport.xlsx"
Const xlsTabName = "My_XLX_Tab_Name"
Const tmpQueryName = "temp_error"
Dim sql As String, qdf As QueryDef
On Error Resume Next
DoCmd.DeleteObject acQuery, tmpQueryName
On Error GoTo 0
sql = "SELECT * FROM qry_temp_error WHERE LogDate BETWEEN #" & busStartDate & "# AND #" & busEndDate & "#"
Set qdf = CurrentDb.CreateQueryDef(tmpQueryName, sql)
DoCmd.TransferSpreadsheet acExport, , tmpQueryName, xlsFileName, True
DoCmd.DeleteObject acQuery, tmpQueryName
MsgBox "Exported to: " & xlsFileName
End Sub
Request guidance on how to re-write this code for creating table
Thank you