Navigate subset of records

G

Guest

I need to retrieve a subset of records in a specific order and I can do that
using SQL.

Having retrieved the records my problems start - I don't know the syntax to
navigate through the records and access the field values that I am after.

Any guidance, please
 
D

Dirk Goldgar

In
Graham said:
I need to retrieve a subset of records in a specific order and I can
do that using SQL.

Having retrieved the records my problems start - I don't know the
syntax to navigate through the records and access the field values
that I am after.

Any guidance, please

Are you talking about opening a recordset on the query, and then
navigating within the recordset? That's pretty straightforward:

Dim rs As DAO.Recordset

Set rs = CurrentDb.OpenRecordset( _
"SELECT * FROM MyTable WHERE SomeField = SomeValue")

With rs
Do Until .EOF
If !MyNumberField = 123 Then
' do something
End If
If !MyTextField = "Some Text" Then
' do something else
End If
.MoveNext
Loop
.Close
End With
 
G

Guest

Hi Dirk

That looks to be exactly what I was after.

Now, to implement it and see how I go.
 
G

Guest

Hi Dirk

Just started to do the implementation and the line
Dim rs As DAO.Recordset
gives a Compile error: User-defined type not defined.

I followed help on the error dialog which led me to the References dialog,
but I have no idea which entry should be checked so that the Dim will compile.

Using Access 2002.

Thanks
 
R

RoyVidar

Graham said:
Hi Dirk

Just started to do the implementation and the line
Dim rs As DAO.Recordset
gives a Compile error: User-defined type not defined.

I followed help on the error dialog which led me to the References
dialog, but I have no idea which entry should be checked so that the
Dim will compile.

Using Access 2002.

You need a reference to Microsoft DAO 3.6 Object Library.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top