Excel export to Access
Arthur,
Thank you.
I tried it but am still getting an error message:
Run-time error '-2147217913 (80040e07)':
Data type mismatch in criteria expression.
And in the vba screen, con.Execute strSQL is hi-lighted yellow with a
yellow arrow to it.
I'm sorry to be a pain, hope you will help me.
Thank you
" wrote:
Goto ViewsToolbarsControl Toolbox then
In sheet2 of your workbook
add a command button then double click that button.
You will be directed to Visual basic editor.
Copy and paste this code inside the "Private Sub
CommandButton1_Click()"
Dim con As New ADODB.Connection
Dim strcon As String
Dim strSQL As String
strcon = "Provider=Microsoft.Jet.OLEDB.4.0;"
strcon = strcon & "Data Source=C:\db1.mdb;"
strcon = strcon & "Persist Security Info=False"
con.Open strcon
strSQL = "INSERT INTO TABLE1 "
strSQL = strSQL & "SELECT * FROM "
strSQL = strSQL & "[Excel 8.0;Database=C:\book1.xls].[Sheet1$]"
con.Execute strSQL
Be sure to replace the
Database=C:\book1.xls,
Data Source=C:\db1.mdb
TABLE1
Finally, RUN the code by pressing F5
|