SELECT * problem in VB

  • Thread starter Thread starter shaggles
  • Start date Start date
S

shaggles

I'm having a problem running a very simple SQL query in
VB. It runs fine on it's own but when I try to run it in
VB I get an 'object does not exist' error message. Can
anyone tell me what I'm doing wrong? Here's my code:
Function Backup_Exam_Data()
On Error GoTo Err_Backup
Dim strExam
Dim strDate As Date
MsgBox "Please insert disk in drive A."
strDate = InputBox("Enter date of earliest exam or trade
review.")
strExam = "SELECT * FROM tblCombinedExam WHERE
ExamDate>=strDate;"
DoCmd.TransferSpreadsheet acExport, 8,
strExam, "A:\ExamBackup" & Format(Date, "mmddyy")
& ".xls", True
Exit_Backup:
Exit Function
Err_Backup:
MsgBox Err.Description
Resume Exit_Backup
End Function
 
try:
strExam = "SELECT * FROM tblCombinedExam WHERE
ExamDate>=#" & format(strDate,"mm\/dd\/yyyy") & "#"
 
I'm still getting an error message that says "The
Microsoft Jet Database engine could not find the
object 'SELECT * FROM tblCombinedExam WHERE
ExamDate>=#04/19/2004#'."
 
ahh, yes, in TransferSpreadsheet you can use query or table. so try to
select into temporary table, and then TransferSpreadsheet this table
 
Back
Top