Delete Query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to run a delete query with VB but I'm having trouble getting
started. Ideally, I would like to do this from outside of my database. The
user would like to push a button on an Excel spreadsheet that would kick off
the delete query. Thanks for the help......
 
I would like to run a delete query with VB but I'm having trouble
getting started. Ideally, I would like to do this from outside of my
database. The user would like to push a button on an Excel
spreadsheet that would kick off the delete query. Thanks for the
help......

It's practically the same as in Access, except that Excel won't open the
database for you so you have to do it yourself.

public sub ExcelProc()
dim dbe as new dao.dbengine

dim db as dao.database
set db = dbe.OpenDatabase("c:\blah.mdb",false, false)

dim jetSQL as string
jetSQL = "DELETE FROM MyTable WHERE MyPK = 1028"

db.Execute jetSQL, dbFailOnError

db.Close
set db = nothing
set dbe = nothing

end sub


Hope that helps


Tim F
 
Back
Top