Sub GetMyData()
Dim cn As New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\josh\Investment.mdb;User id=admin;"
cn.Open
Dim cmd As New ADODB.Command
Set cmd.ActiveConnection = cn
'cmd.CommandText = "Delete * From Clients Where FirstName='" & Range("E2") & "'"
cmd.CommandText = "Update Clients Set FirstName='John' Where SSN='111111111'"
cmd.Execute
Exit Sub
Dim rs As ADODB.Recordset
Set rs = cmd.Execute
Dim I As Integer
I = 1
While Not rs.EOF
Range("A" & I).FormulaR1C1 = rs("FirstName")
Range("B" & I).FormulaR1C1 = rs("LastName")
I = I + 1
rs.MoveNext
Wend
End Sub
Wednesday, December 3, 2008
Connecting to an Access Database from Excel Using VBA
Posted by joshwaxman at 5:18 PM
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment