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.
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.