SELECT * problem in VB

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
 
A

Alex Dybenko

try:
strExam = "SELECT * FROM tblCombinedExam WHERE
ExamDate>=#" & format(strDate,"mm\/dd\/yyyy") & "#"
 
S

shaggles

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#'."
 
A

Alex Dybenko

ahh, yes, in TransferSpreadsheet you can use query or table. so try to
select into temporary table, and then TransferSpreadsheet this table
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top