View Full Version : SQL in VBA Transfer Spreadsheet


bradh_nz
01-12-2009, 11:57 PM
Hi

I have the below code to transfer a spreadsheet and name the spreadsheet based on an sql Query (HFile) however I cannot seem to get this to work. Any help appreciated.
-----------------------------------------
Option Compare Database
Function Export_RC()
Dim strInput As String
Dim strMsg As String

strInput = HFile

DoCmd.TransferSpreadsheet acExport, 8, "RC", "\\Chad-pl05\GIM\Systems\Issues\63 (file://Chad-pl05/GIM/Systems/Issues/63) - Basel Late Adjustments\2009 BASEL Update Work\" & strInput & ".xls", True, ""
End Function
-----------------------------------

Function HFile()
Dim db As Database
Dim Rs As Recordset
Dim sSQLstr As String
Set db = CurrentDb
sSQLstr = "SELECT Details.Hfile " & _
" FROM Details "
Set Rs = db.OpenRecordset(sSQLstr)
Rs.Close

End Function

gemma-the-husky
01-13-2009, 02:35 AM
your hfile function isnt returning anything

try setting strinput to an explicit file first to make sure the docmd bit works - then go back to the hfile function