Solved

DAO Recordset Select Statement

Posted on 2006-11-14
1
747 Views
Last Modified: 2008-01-09
Hi,

Can anyone tell me or point me to the VBA which I can

a)Create a recordset (Dim ThisRecordset As DAO.Recordset)

b)Fill this record set using a specific Sql Statement ("SELECT * FROM MyTable WHERE FieldA = 1")

Thanks in advance

Andrew
0
Comment
Question by:REA_ANDREW
1 Comment
 
LVL 1

Accepted Solution

by:
jkanisut earned 500 total points
ID: 17939330
Dim db As DAO.Database
Set db = OpenDatabase(sDBPath, False, False, "ODBC;SERVER=Server;UID=user;PWD=password;DSN=ODBCentry)

Dim sSql as string
sSql = "SELECT * FROM MyTable WHERE FieldA = 1"

Dim rs As DAO.Recordset
Set rs = db.OpenRecordset(sSql, dbOpenSnapshot)

Do While rs.EOF
data = rsFields("fieldname")
rs.MoveNext
Loop

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

760 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

24 Experts available now in Live!

Get 1:1 Help Now