Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DoCmd.SetWarnings False
- Dim db As Database
- Dim rs As Recordset
- Set db = CurrentDb
- Dim path As String
- path = CurrentProject.path & ""& "BTO Export.xlsx"
- Dim mySql As String
- On Error GoTo HandleError
- mySql = "SELECT DISTINCT TABLEDD.[Code] as [ID] From TABLEDD"
- On Error Resume Next
- CurrentDb.QueryDefs.Delete "temp2"
- On Error GoTo 0
- db.CreateQueryDef "temp2", mySql
- DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "temp2", CurrentProject.path & "" & " IDS Generated" & Format(Now(), " mm dd yyyy hh mm"), True
- CurrentDb.QueryDefs.Delete "temp2"
- Set db = Nothing
- DoCmd.SetWarnings True
- MsgBox "List of IDS processed successfully"
- Exit Sub
- HandleError:
- MsgBox Err.Description
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement