I'm trying to add data into an access DB from Excel, I wan to add many values in one go.
The issue is that Excel reports that the SQL is missing the trailing semi-colon (;) Here is the extract of the code with the SQL that fails.
This is the built SQL Statment
INSERT INTO ThisTable (FirstName, LastName) VALUES ('John','Smith'),('Ringo','Star'),('Chris','Jones');
' --- Test Access Creation --- '
Sub Example2()
'the path to create the new access database
Dim strPath As String
'an DAO object
Dim db As DAO.Database
Dim command As String
Let command = "INSERT INTO ThisTable (FirstName, LastName) " & _
"VALUES " & _
"('John','Smith')," & _
"('Ringo','Star')," & _
"('Chris','Jones');"
Debug.Print command
strPath = "A:\NewDB"
Set db = DAO.OpenDatabase(strPath)
'Set db = DAO.CreateDatabase(strPath, DAO.dbLangGeneral)
'db.Execute "CREATE TABLE ThisTable " _
& "(FirstName CHAR, LastName CHAR);"
db.Execute command
Dim rst As DAO.Recordset
Set rst = db.OpenRecordset("Select * FROM ThisTable")
'Begin row processing
Do While Not rst.EOF
Debug.Print Trim(rst.Fields(0)) & " " & Trim(rst.Fields(1))
rst.MoveNext
Loop
db.Close
End Sub
VALUES. You have to use multipleUNIONs instead.