?
Solved

Running Queries made in ACCESS

Posted on 1998-10-04
3
Medium Priority
?
114 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 100 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

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.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 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…
Suggested Courses

764 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