D
Dirt Bike
So I did some research and came across a similar question and the helpful guy
linked to his accessmvp site or some such. That helped me get somewhat off
ground zero. But, and please don't laugh because i am such a VBA idiot
but.....when I try to put a WHERE in the code below I either get a Error,
expecting at least one parameter or "the database cannot find table or query
'False'..."
When I pull out the WHERE I get the results I need. The SQL look at a query
to do the same thing is WHERE (((Forecast.WhoResp)="Dudley"));
How do i do that in VBA with all the requisite & "].[" and the like...geese
this is killing me to be soooooooo ignorant.
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click
Set objDB = CurrentDb
Const strFileName As String = "test"
Const strQName As String = "zExportQuery"
Dim strWorksheet(3) As String
strWorksheet(0) = "Dudley"
strWorksheet(1) = "Worksheet2"
strExcelFile = "W:\datafiles\spreadsheet"
objDB.Execute _
"SELECT * INTO [Excel 8.0;DATABASE=" & strExcelFile & "].[" _
& strWorksheet(0) & "] FROM qryForecast WHERE " & _
"[" & qryForecast & "].[" & WhoResp & "]" = "Dudley" & ";"
objDB.Close
MsgBox "Succesful!"
Set objDB = Nothing
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
End Sub
linked to his accessmvp site or some such. That helped me get somewhat off
ground zero. But, and please don't laugh because i am such a VBA idiot
but.....when I try to put a WHERE in the code below I either get a Error,
expecting at least one parameter or "the database cannot find table or query
'False'..."
When I pull out the WHERE I get the results I need. The SQL look at a query
to do the same thing is WHERE (((Forecast.WhoResp)="Dudley"));
How do i do that in VBA with all the requisite & "].[" and the like...geese
this is killing me to be soooooooo ignorant.
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click
Set objDB = CurrentDb
Const strFileName As String = "test"
Const strQName As String = "zExportQuery"
Dim strWorksheet(3) As String
strWorksheet(0) = "Dudley"
strWorksheet(1) = "Worksheet2"
strExcelFile = "W:\datafiles\spreadsheet"
objDB.Execute _
"SELECT * INTO [Excel 8.0;DATABASE=" & strExcelFile & "].[" _
& strWorksheet(0) & "] FROM qryForecast WHERE " & _
"[" & qryForecast & "].[" & WhoResp & "]" = "Dudley" & ";"
objDB.Close
MsgBox "Succesful!"
Set objDB = Nothing
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
End Sub