SQL syntax

K

Khoa

Hi all,
I have a function (copied from another thread) like this:
'--------Code start-----------
Function AutoExec()
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sqlCmd As String
Set conn = New ADODB.Connection
conn.ConnectionString = "DSN=Visual FoxPro
Tables;SourceDB=C:\Temp;SourceType=DBF;Exclusive=No;Deleted=Yes;"
conn.Open
sqlCmd = "SELECT * FROM Hello;"
Set rs = New ADODB.Recordset
rs.Open sqlCmd, conn, adOpenDynamic, adLockOptimistic
Do Until rs.EOF
CurrentDb.Execute "Insert Into tblHello (Field1) Values (""" &
rs.Fields(0).Value & """)"
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
End Function
'---------Code end---------
I wonder if instead of Insert record by record, is there a way to append all
record at once, such as:
CurrentDb.Execute "Insert Into tblHello SELECT * FROM ... "
Any idea would be appreciated.
 
D

Douglas J. Steele

What you're suggesting ("Insert Into tblHello SELECT * FROM ... ") is
exactly how to do it, down to being the correct syntax!

What happens when you try?
 

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