gyferlotus
New Member
- Joined
- Oct 14, 2010
- Messages
- 17
I have one Excel row populated by:
1 2 3 <-- First Row
I want to take the row and insert it in a Access Database.
The problem is that if I run the code a second time, the table won't
change. The table called MyTable always stays with just 1 row of (1 2 3)
I want the Access Table to keep storing, the first row that im adding
So the output of the Table should be
1 2 3
1 2 3
1 2 3
1 2 3
etc
Could anyone help me fix this?
Also I would like to know which would be a good SQL command to see
the contents of the table called "MyTable".
Thanks in advance
1 2 3 <-- First Row
I want to take the row and insert it in a Access Database.
The problem is that if I run the code a second time, the table won't
change. The table called MyTable always stays with just 1 row of (1 2 3)
I want the Access Table to keep storing, the first row that im adding
So the output of the Table should be
1 2 3
1 2 3
1 2 3
1 2 3
etc
Code:
Dim sConnect As String, sSQL As String
Dim db As ADODB.Connection, Str As String, Source As String, Origin As String
On Error Resume Next
Origin = "C:\Users\Sam\Desktop\book2.xlsx"
Source = "C:\Users\Sam\Desktop\Database4.accdb"
Str = "[Sheet1$A1:C1]"
Set db = New ADODB.Connection
db.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & _
Source & ";Persist Security Info=False;"
sConnect = "'" & Origin & "' 'Excel 8.0;HDR=Yes;'"
sSQL = "SELECT * INTO " & "MyTable" & " FROM " & Str & " IN " & sConnect
db.Execute sSQL
Could anyone help me fix this?
Also I would like to know which would be a good SQL command to see
the contents of the table called "MyTable".
Thanks in advance