Hi everyone,
I'm kind of a newbie, when programming in VB so i'm having a little bit of trouble exporting a simple query result to a excel file.
I've found this code that works fine when i use a table:
Const FILE_PATH As String = "C:\My Documents\"
Dim FULLPath As String
strFullPath = FILE_PATH
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel7, "tbl_name", strFullPath & "Test.xls", False
MsgBox ("Export Complete")
How can i do this using a query?
Let's say my query is:
strSQL = "SELECT ID, NomeCandidato, DataEntrada FROM FichaCandidatura"
I've tried to do this
Const FILE_PATH As String = "C:\My Documents\"
Dim FULLPath As String
strFullPath = FILE_PATH
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel7, "strSQL", strFullPath & "Test.xls", False
MsgBox ("Export Complete")
but is says that it can't find the object "strSQL".
How do i define my query to use in that line?
Can anyone help me?