T
Tamer
I'm about to lose my mind. I spent a long time trying to
pass an SQL statement to a query as follows. Somebody
please help, what am I missing?? It's giving me a syntax
error message for the SQL statement.
Dim db As DAO.Database
Dim rs As Recordset
Dim SQL As String
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
SQL = "SELECT [CaseName], [ChildName] FROM
[qry_UCRsFinal]" & "WHERE Supervisor = " & InputBox("Which
Supervisor?") & ";"
Set db = CurrentDb
Set rs = db.OpenRecordset(SQL, dbOpenSnapshot)
Set xlApp = CreateObject("excel.application")
With xlApp
.Visible = True
.WindowState = xlMinimized
End With
Set xlBook = xlApp.Workbooks.Add
xlBook.SaveAs FileName:="\\evolvserver\MIS\UCR
Tickler\UCRsSups"
Set xlSheet = xlBook.Worksheets.Add
xlSheet.Name = "UCRs By Supervisor"
xlSheet.Cells.Range("a2").CopyFromRecordset rs
xlBook.Save
Set xlBook = Nothing
Set xlSheet = Nothing
Set xlApp = Nothing
rs.Close
Set rs = Nothing
'Set prm = Nothing
'Set qdf = Nothing
'Set db = Nothing
End Sub
pass an SQL statement to a query as follows. Somebody
please help, what am I missing?? It's giving me a syntax
error message for the SQL statement.
Dim db As DAO.Database
Dim rs As Recordset
Dim SQL As String
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
SQL = "SELECT [CaseName], [ChildName] FROM
[qry_UCRsFinal]" & "WHERE Supervisor = " & InputBox("Which
Supervisor?") & ";"
Set db = CurrentDb
Set rs = db.OpenRecordset(SQL, dbOpenSnapshot)
Set xlApp = CreateObject("excel.application")
With xlApp
.Visible = True
.WindowState = xlMinimized
End With
Set xlBook = xlApp.Workbooks.Add
xlBook.SaveAs FileName:="\\evolvserver\MIS\UCR
Tickler\UCRsSups"
Set xlSheet = xlBook.Worksheets.Add
xlSheet.Name = "UCRs By Supervisor"
xlSheet.Cells.Range("a2").CopyFromRecordset rs
xlBook.Save
Set xlBook = Nothing
Set xlSheet = Nothing
Set xlApp = Nothing
rs.Close
Set rs = Nothing
'Set prm = Nothing
'Set qdf = Nothing
'Set db = Nothing
End Sub