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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert into a new table 1

Status
Not open for further replies.

leshok

Technical User
Jun 14, 2006
2
US
I am trying to create a form that takes data from one table and inserts it inot a new table. I keep getting the following error

Run-time error '3075'

Syntax error (missing operator) in query expression

If anyone could provide some help I would really appreciate it.

Thank you
 
Welcome to Tek-Tips.
Please read carefully this: FAQ181-2886

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
My guess would be that you have a syntax error in your query.
 
I am able to read all the data from my table, but during the RunSQL part the insert into statment is not working for me for the Path field. When I am in debug mode I am able to view the data that is in path, but I still don't understand why the code does not insert into. Below is my code if that helps.

Private Sub Command4_Click()

Dim DBS As Database
Dim RST As Recordset
Dim Path As String
Dim Book As Single
Dim FirstDoc As Single
Dim LastDoc As Single
Dim I As Single
Dim INTableName As String
Dim OutTableName As String

INTableName = "Condo"
OutTableName = "Condo_Path"

Set DBS = CurrentDb
Set RST = DBS.OpenRecordset(INTableName)
If RST.BOF = False Then RST.MoveFirst
While RST.EOF = False

Path = Left(RST.Fields("Path").Value, 38)
Book = Left(RST.Fields("Book").Value, 4)
FirstDoc = Right(RST.Fields("FirstDoc").Value, 4)
If IsNull(RST.Fields("LastDoc").Value) = False Then
LastDoc = Right(RST.Fields("LastDoc").Value, 4)
DoCmd.SetWarnings False
For I = FirstDoc To LastDoc
DoCmd.RunSQL ("Insert Into " & OutTableName & " (Path, Book, Start) Values (" & Path & "," & Book & "," & I & ")")

Next I

Else

DoCmd.RunSQL ("Insert Into " & OutTableName & "(Path, Book, Start) VALUES (" & Path & "," & Book & "," & Right(RST.Fields("Start").Value, 5) & ")")
End If

RST.MoveNext
I = 0
Wend
DoCmd.SetWarnings True
 
DoCmd.RunSQL ("Insert Into " & OutTableName & " (Path, Book, Start) Values ([!]'[/!]" & Path & "[!]'[/!]," & Book & "," & I & ")")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top