Select into Error

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
 
S

Sylvain Lafontaine

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.
 

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