Solved

Running Queries made in ACCESS

Posted on 1998-10-04
3
111 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
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

810 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