By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,921 Members | 1,321 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,921 IT Pros & Developers. It's quick & easy.

Another Syntax Question

P: 7
I Get "Syntax error in query. Incomplete query clause." (3450) while running this code:
Expand|Select|Wrap|Line Numbers
  1.        strSQL = "SELECT Calendar.MyDate, Calendar.MyTime, Calendar.Currency, Calendar.[Data Released]," & _
  2.             " Calendar.Forecast, Calendar.Previous, Calendar.Impact, [" & tblname & "].F2," & _
  3.             " [" & tblname & "].F3, [" & tblname & "].F4, [" & tblname & "].F5," & _
  4.             " [" & tblname & "].F6, [" & tblname & "].F7" & _
  5.             " INTO " & varData(i) & " " & _
  6.             " FROM Calendar INNER JOIN [" & tblname & "] ON Calendar.MyDate = [" & tblname & "].F1" & _
  7.             " WHERE (((Calendar.Currency)='" & varData(i) & "') AND (([" & tblname & "].F2)" & _
  8.             " Between [Calendar].[MyTime] And [Calendar].[Limit]));"
  9.         DoCmd.RunSQL strSQL
Can anyone spot the problem?
Thanks a bunch in advanced!
Tomba.
Dec 30 '06 #1
Share this Question
Share on Google+
3 Replies


P: 7
Ok, I got the syntax right, but now I have another problem - sorry for bothering:\
For some reason, after running the code below, the records on the table I've created gets deleted (access prmopts me a dialogue box notifying that the existing table I created is going to be deleted before the query is executed, and asking me whether I want to continue or not).
I'll really appreciate any further help!
Expand|Select|Wrap|Line Numbers
  1. Do
  2.     If varData(i) <> "EUR" Then
  3.         strSQL = "SELECT Calendar.MyDate, Calendar.MyTime, Calendar.Currency, Calendar.[Data Released]," & _
  4.             " Calendar.Forecast, Calendar.Previous, Calendar.Impact, [" & tblname & "].F2," & _
  5.             " [" & tblname & "].F3, [" & tblname & "].F4, [" & tblname & "].F5," & _
  6.             " [" & tblname & "].F6, [" & tblname & "].F7" & _
  7.             " INTO [" & varData(i) & "-" & tblname & "]" & _
  8.             " FROM Calendar INNER JOIN [" & tblname & "] ON Calendar.MyDate = [" & tblname & "].F1" & _
  9.             " WHERE (((Calendar.Currency)='" & varData(i) & "')" & _
  10.             " AND (([" & tblname & "].F2) Between [Calendar].MyTime And [Calendar].Limit));"
  11.     Else
  12.         strSQL = "SELECT Calendar.MyDate, Calendar.MyTime, Calendar.Currency, Calendar.[Data Released]," & _
  13.             " Calendar.Forecast, Calendar.Previous, Calendar.Impact, [" & tblname & "].F2," & _
  14.             " [" & tblname & "].F3, [" & tblname & "].F4, [" & tblname & "].F5," & _
  15.             " [" & tblname & "].F6, [" & tblname & "].F7" & _
  16.             " INTO [" & varData(i) & "-" & tblname & "]" & _
  17.             " FROM Calendar INNER JOIN [" & tblname & "] ON Calendar.MyDate = [" & tblname & "].F1" & _
  18.             " WHERE (((Calendar.Currency)='EUR' OR (Calendar.Currency)='E-12' OR (Calendar.Currency)='GER')" & _
  19.             " AND (([" & tblname & "].F2) Between [Calendar].MyTime And [Calendar].Limit));"
  20.     End If
  21.     i = i + 1
  22.     DoCmd.RunSQL strSQL
  23. Loop Until i = 2
Thanx alot!
Tomba.
Dec 30 '06 #2

NeoPa
Expert Mod 15k+
P: 31,492
SELECT INTO (What you're using) is a Make Table query.
That's what they do if they find the destination table already exists.
You probably want an INSERT INTO (Append) query instead.
Remember to clear the existing records first when you run it - assuming that's what you need it to do.
Dec 31 '06 #3

MMcCarthy
Expert Mod 10K+
P: 14,534
SELECT INTO (What you're using) is a Make Table query.
That's what they do if they find the destination table already exists.
You probably want an INSERT INTO (Append) query instead.
Remember to clear the existing records first when you run it - assuming that's what you need it to do.
Append query syntx ...

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO Tablename1 (Field1, Field2)
  2. SELECT Field1, Field2
  3. FROM TableName2;
Mary
Jan 1 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.