Solved

Running Queries made in ACCESS

Posted on 1998-10-04
3
112 Views
Last Modified: 2010-04-30
Is it possible to run queries defined in ACCESS using VB 5.0? If it is, how can it be done?  If not, what is a good alternative?
0
Comment
Question by:wsanchez
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Expert Comment

by:MelissaC
ID: 1438127
With ADO, I thought it was

dim conn as ADODB.Connection
dim rs as ADODB.Recordset
dim sql as string
sql="put your queryname here"

conn.Open DSN, ...
rs.open sql conn,1,3
0
 
LVL 5

Accepted Solution

by:
chewhoung earned 50 total points
ID: 1438128
Yes you can.

To run a query in access from vb, first you must open the database.

    Set MyDB = OpenDatabase("C:\Yourdatabase.mdb")

To execute an append/update/delete query, use the execute method:

    MyDB.Execute "Your Query Name"

To retrieve data from a query, use openrecordset method:

    Set rstRecordset = MyDB.OpenRecordset("Your Query Name", dbOpenDynaset)

    With rstRecordset
         ...do something
         ...do something
    End With

    rstRecordset.close
0
 

Author Comment

by:wsanchez
ID: 1438129
I'll try that out.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question