S
Suncobra9
A code I have been trying to run gave me the message "Syntax error in INSERT
INTO statement." I haven't had any luck figuring out exactly what is wrong
with the code. Any input would be appretiated.
Option Compare Database
Option Explicit
Dim strSymbol As String
Dim dteLineDate As Date
Dim intRef As Integer
Dim strSQL As String
Dim dbs As Database
Dim rst As Recordset
Private Sub CopyData()
On Error GoTo Err_CopyData
strSymbol = InputBox("Enter Symbol Code:")
intRef = -63
dteLineDate = DMin("[DATE]", "[RAW DATA]", "[SYMBOL] = '" & strSymbol & "'")
While intRef < -51
strSQL = "INSERT INTO INTERMEDIATE (SYMBOL, DATE, HIGH, " & _
"LOW, LAST, VOLUME) SELECT [RAW DATA].SYMBOL, " & _
"[RAW DATA].DATE, [RAW DATA].HIGH, [RAW DATA].LOW, " & _
"[RAW DATA].LAST, [RAW DATA].VOLUME FROM [RAW DATA] " & _
"WHERE (([RAW DATA].SYMBOL = '" & strSymbol & "')" & _
"AND ([RAW DATA].DATE = #" & dteLineDate & "#))"
DoCmd.RunSQL strSQL
intRef = intRef + 1
NextDate:
dteLineDate = dteLineDate + 1
strSQL = "SELECT * FROM [RAW DATA] WHERE " & _
"(([DATE] =#" & dteLineDate & "#) AND ([SYMBOL] ='" & strSymbol &
"'))"
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strSQL)
If DCount("*", "rst") = 0 Then
Set rst = Nothing
Set dbs = Nothing
GoTo NextDate
Else
Set rst = Nothing
Set dbs = Nothing
End If
Wend
Exit Sub
Err_CopyData:
MsgBox Err.Description
Exit Sub
End Sub
INTO statement." I haven't had any luck figuring out exactly what is wrong
with the code. Any input would be appretiated.
Option Compare Database
Option Explicit
Dim strSymbol As String
Dim dteLineDate As Date
Dim intRef As Integer
Dim strSQL As String
Dim dbs As Database
Dim rst As Recordset
Private Sub CopyData()
On Error GoTo Err_CopyData
strSymbol = InputBox("Enter Symbol Code:")
intRef = -63
dteLineDate = DMin("[DATE]", "[RAW DATA]", "[SYMBOL] = '" & strSymbol & "'")
While intRef < -51
strSQL = "INSERT INTO INTERMEDIATE (SYMBOL, DATE, HIGH, " & _
"LOW, LAST, VOLUME) SELECT [RAW DATA].SYMBOL, " & _
"[RAW DATA].DATE, [RAW DATA].HIGH, [RAW DATA].LOW, " & _
"[RAW DATA].LAST, [RAW DATA].VOLUME FROM [RAW DATA] " & _
"WHERE (([RAW DATA].SYMBOL = '" & strSymbol & "')" & _
"AND ([RAW DATA].DATE = #" & dteLineDate & "#))"
DoCmd.RunSQL strSQL
intRef = intRef + 1
NextDate:
dteLineDate = dteLineDate + 1
strSQL = "SELECT * FROM [RAW DATA] WHERE " & _
"(([DATE] =#" & dteLineDate & "#) AND ([SYMBOL] ='" & strSymbol &
"'))"
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strSQL)
If DCount("*", "rst") = 0 Then
Set rst = Nothing
Set dbs = Nothing
GoTo NextDate
Else
Set rst = Nothing
Set dbs = Nothing
End If
Wend
Exit Sub
Err_CopyData:
MsgBox Err.Description
Exit Sub
End Sub