PC Review Forums Newsgroups Microsoft Access Microsoft Access VBA Modules Delete Query

Reply

Delete Query

 
Thread Tools Rate Thread
Old 16-03-2006, 08:16 PM   #1
=?Utf-8?B?SlQ=?=
Guest
 
Posts: n/a
Default Delete Query


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......
--
JT
  Reply With Quote
Old 16-03-2006, 09:59 PM   #2
Tim Ferguson
Guest
 
Posts: n/a
Default Re: Delete Query

=?Utf-8?B?SlQ=?= <JT@discussions.microsoft.com> wrote in
news:F3897E67-8BC2-4452-B95A-743AA811D655@microsoft.com:

> 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

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off