Insert Into

BBBryan

Registered User.
Local time
Today, 15:19
Joined
Nov 13, 2010
Messages
122
Hi,
Can someone please help me

I am selecting All the data from [ItpTemplateTable tbl]
and coping it into the [ItpDescriptionInfo tbl]
From double clicking in a textbox to copy the Data
There is about 7 Cols - Both tables are exacly the same.

I am getting a error on this - Expected End of statement on the INTO

Private Sub Item_DblClick(Cancel As Integer)
strSQL = INSERT INTO [ItpDescriptionInfo tbl] SELECT * FROM[ItpTemplateTable tbl]
DoCmd.Execute strSQL

End Sub

Thanks BBryan
 
Try

strSQL = "INSERT INTO [ItpDescriptionInfo tbl] SELECT * FROM [ItpTemplateTable tbl]"
CurrentDb.Execute strSQL
 
Hi PBady,
Thanks
I tried this and I guess I didn't have exacly the same feilds. I have more in the [ItpDescriptionInfo tbl] Table.
Now I just tried from the [ItpTemplateTable tbl] the name of the cols Like this...

"strSQL = Insert Into [ItpDescriptionInfo tbl] ([SortOrder], [Item], [Description], [Sub Description], [InfoDescription], [2ndInfoDescription], [Documentation]) Select FROM [ItpTemplateTable tbl] [SortOrder], [Item], [Description], [Sub Description], [InfoDescription], [2ndInfoDescription], [Documentation])"
I now get a complie error on this one...Line Number or label or Expected end of statement.


thanks BBryan
 
Your syntax is wrong in the SELECT part. You need the fields before FROM, just the table after.
 
Oh, and you start the quotes before strSQL, should be before Insert.
 
Hi PBady,
Sorry - I noticed I had made some mistakes on the last statement
I should have said this But this also has a syntax error.

strSQL = "Insert INTO [Itp Piping tbl] ([SortOrder], [Item], [Description], [Sub Description], [InfoDescription], [2ndInfoDescription], [Documentation]) Select FROM [Itp Template Table tbl] ([SortOrder], [Item], [Description], [Sub Description], [InfoDescription], [2ndInfoDescription], [Documentation])"

Thanks BBryan
 
Sorry PBady,


I just am not getting this right

strSQL = "Insert INTO [Itp Piping tbl] ([SortOrder], [Item], [Description], [Sub Description], [InfoDescription], [2ndInfoDescription], [Documentation]) Select ([SortOrder], [Item], [Description], [Sub Description], [InfoDescription], [2ndInfoDescription] , [Documentation]) FROM [Itp Template Table tbl]"
CurrentDb.Execute strSQL
I think this is how I was supposed to do this
I am still getting a syntax error.Comma in query expression.
Note:(I changed the name of the one Table)

Thanks BBryan
 
Try

strSQL = "Insert INTO [Itp Piping tbl] ([SortOrder], [Item], [Description], [Sub Description], [InfoDescription], [2ndInfoDescription], [Documentation]) Select [SortOrder], [Item], [Description], [Sub Description], [InfoDescription], [2ndInfoDescription] , [Documentation] FROM [Itp Template Table tbl]"
 
Sorry PBady,


I just am not getting this right

strSQL = "Insert INTO [Itp Piping tbl] ([SortOrder], [Item], [Description], [Sub Description], [InfoDescription], [2ndInfoDescription], [Documentation]) Select ([SortOrder], [Item], [Description], [Sub Description], [InfoDescription], [2ndInfoDescription] , [Documentation]) FROM [Itp Template Table tbl]"
CurrentDb.Execute strSQL
I think this is how I was supposed to do this
I am still getting a syntax error.Comma in query expression.
Note:(I changed the name of the one Table)

Thanks BBryan
 
Did you try post 9 (that's not what I posted)? If so, can you post the db here?
 
Sorry again,
I lost the internet connection and it double entered the reply.
I tried post 9
It also has a error 3061:
; too few parameters, Expected 1
My data base it 460 MB
But I might be able to just put this part in another Database.
I have to do somthing for a hour or so I will send after.

and Thanks For Help.

Thanks BBryan
 
That makes me suspect something is spelled wrong. Why not just create a saved query and execute it?
 
Hi Pbady,
I just returned.
Something may be spelled wrong - Could it be that I am doing this from a sub form within a sub form? Do I need to state the Insert Into a the form Name and not the table name?
when you say a saved query and execute it.
I am not sure how to add the data from the query into the form I have. Is it the same way as the Insert into statement. If I make a Query Named [ItpTemplate Query]
INSERT INTO Forms![WorkOrder Fm]![ItpDescription fm]![Itp fm] SELECT * FROM [ItpTemplate Query]


thanks BBryan
 
You're going table to table, so the form is irrelevant, and would not be part of the query. You'd append the data and then open or requery the form to view the records. I'd just execute a saved query rather than build it in code, but it should work either way with the correct syntax.
 
Thanks for your Help.

I see how you would do that. I will try that.

Thanks BBryan
 
No problem; post back if you get stuck.
 
Hi Pbaldy,
I was going to send this example of what I was doing.
I just took this part out of my database. If you still wanted to look at it.
Double click into the Item textBox in the 2nd dropdown.

Thanks Bryan Hewitt
 

Attachments

Users who are viewing this thread

Back
Top Bottom