Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query input must contain at least one table or query. 1

Status
Not open for further replies.

Eprice

Technical User
May 6, 2003
209
US
Hi,
I have access 2002 and am trying to modify sql with visual basic. But I get the error 'Query input must contain at least one table or query'. I can't find anything wrong with my string looking at it with a message box so maybe the problem is the query is actually a make table query and I can't set the sql this way. Here is my code:

Set qry = CurrentDb().QueryDefs("qry SelectLisa")

strsql = "INSERT INTO AuditComparisonRecords ( FieldOffice, Physical, Telephone, MailForm, CurMonth, CurYear, CompareMonth )" & _
"SELECT [tbl AuditComparisonRecords].FieldOffice, [tbl AuditComparisonRecords].Physical, [tbl AuditComparisonRecords].Telephone, [tbl AuditComparisonRecords].MailForm, [Forms]![frm AuditProduction]![MyMonth] AS CurMonth, [Forms]![frm AuditProduction]![MyYear] AS CurYear, DateAdd('m',2,[Forms]![frm AuditProduction]![MyDate]) AS CompareMonth" & _
"From [tbl AuditComparisonRecords]WHERE ((([tbl AuditComparisonRecords].FieldOffice)=" & "'" & strCriteria & "'" & "));"
MsgBox strsql
qry.SQL = strsql

Does anyone have any ideas why this will not work?
Thanks
Lisa
 
I'd watch spacing between words and continuations, for example:
Code:
From [tbl AuditComparisonRecords]WHERE
And the lack of a space after AS CompareMonth will concatenate the string to form
Code:
AS CompareMonthFrom
Hope this helps

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Wonderful, it was the spacing. Thank you, HarleyQuinn
 
You're welcome, glad I could help [smile]

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top