Solved

Running Queries made in ACCESS

Posted on 1998-10-04
3
110 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
Comment Utility
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
Comment Utility
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
Comment Utility
I'll try that out.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now