Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[COLOR=blue]
Public Sub Excel1()
Dim dbcon As adodb.Connection
Dim sXlsPath As String
sXlsPath = "C:\MyExcelTable.xls"
Set dbcon = New adodb.Connection
With dbcon
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Data Source") = "C:\MyDatabase.MDB"
.Open
End With
[/color][COLOR=green]
'"myTable" is the table in the Mdb
'"Field1" is a field in "myTable"
'"A" is the xls column name
'"Worksheet1$" is the name of the Worksheet[/color][COLOR=blue]
dbcon.Execute _
"INSERT INTO myTable(Field1) " & _
"SELECT [A] AS Field1 " & _
"From [Worksheet1$] " & _
"IN '" & sXlsPath & "' 'EXCEL 8.0;'"
[/color][COLOR=green]
'To append data from all columns, and all columns are in myTable with the same names, then you can shorten it as:
'dbcon.Execute _
"INSERT INTO myTable " & _
"SELECT * " & _
"From [Worksheet1$] " & _
"IN '" & sXlsPath & "' 'EXCEL 8.0;'"
End Sub[/color]
dim rs as adodb.recordset
dim sCmdTxt as string
Set rs = adodb.recordset
set rs.ActiveConnection = dbcon
sCmdTxt = "SELECT * " & _
"From [Worksheet1$] " & _
"IN '" & sXlsPath & "' 'EXCEL 8.0;'"
"
rs.Open sCmdTxt
do until rs.Eof
'Add records to db table one at a time
loop