View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
merjet merjet is offline
external usenet poster
 
Posts: 812
Default Programming to go between Access and Excel

Is it possible to write code (in Excel's Visual Basic)
that accesses an Access database and deletes all current
records? I want all of this to happen when the user hits
a button that says "update".


Sub macro1()
' Microsoft DAO x.x Object Library at menu
' Tools | References must be checked
Dim rs As Recordset
Dim db As Database

Set db = OpenDatabase("c:\path\filename.mdb")
Set rs = db.OpenRecordset("Table1")
Do
rs.Delete
rs.MoveNext
Loop Until rs.EOF
Set rs = Nothing
Set db = Nothing
End Sub

HTH,
Merjet