Solved

DAO Recordset Select Statement

Posted on 2006-11-14
1
749 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
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…
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…

777 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