By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,659 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

Iterating a table with VB

P: n/a

I have a table with no ID field. I would like to read a single field
of each record using DLookup or something similar and pass it to a VB
function that's already been written. However, DLookup doesn't seem to
be able to "index" a table, but rather returns a field based on some
matching criteria.

What's the simplest way to iterate a table like I need to do in VB? My
VB skills are mediocre and my SQL skills are even worse, so if it's
doable in VB, that might be the best way for me. I don't care how long
the operation takes.

Thanks,
Rich

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
rc*****@comcast.net wrote:
I have a table with no ID field. I would like to read a single field
of each record using DLookup or something similar and pass it to a VB
function that's already been written. However, DLookup doesn't seem
to be able to "index" a table, but rather returns a field based on
some matching criteria.

What's the simplest way to iterate a table like I need to do in VB?
My VB skills are mediocre and my SQL skills are even worse, so if it's
doable in VB, that might be the best way for me. I don't care how
long the operation takes.

Thanks,
Rich


What is the function going to do? Are you sure it can't be done with a query?
Iterating through a table is seldom necessary, but to do so you would create a
RecordSet and loop through it in code.

Dim db As Database
Dim rs As Recordset

Set db = CurrentDB
Set rs = db.OpenRecordset("TableName")

Do Until rs.EOF
YourFunction(rs!FieldName)
rs.MoveNext
Loop
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #2

P: n/a
Thanks Rick.

I'm sure it could be done with a Query. I'm just more comfortable with
VB and don't have the time to get more up to speed on SQL just yet.
Someday....

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.