Select into Error

  • Thread starter Thread starter Cameron
  • Start date Start date
C

Cameron

I am working on writing a function that would filter data and create a table
from it. But I keep getting an error saying that there has to be a table
defined.

I checked the SQL string while running and the varibles are defined so i am
kind of baffled why it gives me this error.

The code in my function is as follows:

Function BuildNew() ' Filters EmpSessions table and builds new session
tables from the filtered data

Dim db As Database
Dim rst As Recordset
Dim sSql As String


Set db = CurrentDb()
Set rst = db.OpenRecordset("SessionType")
rst.MoveFirst
Do Until rst.EOF ' look through records
sSql = "SELECT EmpSessions.EmpID, EmpSessions.CourseID,
EmpSessions.SessionID, EmpSessions.CertificationDate, EmpSessions.ExpiryDate,
EmpSessions.Followup INTO " & rst("CatTable")
sSql = sSql & "FROM (TrainingTypeLookup INNER JOIN CoursesMaster ON
TrainingTypeLookup.TrainingType = CoursesMaster.TrainingType) INNER JOIN
EmpSessions ON CoursesMaster.CourseID = EmpSessions.CourseID"
sSql = sSql & "WHERE (((TrainingTypeLookup.TrainingType)= '" &
rst("Catagory") & " '));"
'db.Execute sSql ' builds new tables
DoCmd.RunSQL sSql
Loop
rst.Close
Set rst = Nothing

End Function
 
Probably a missing space before the FROM and the WHERE keywords. Display
the whole string for debugging purpose. Also, this newsgroup is about ADP
and SQL-Server and has nothing to do with JET/Access and its particular
syntax for queries.
 
Back
Top