Discussion Locked

Walk through table in MS Access VBA

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I need to walk through the rows of a table and test each in a Select Case. I have looked at For Each but can't determine what the syntax would be.

I don't really write in VBA anymore and I'm stumped.

Thanks.

3 replies

by john_wills

I don't know what yu're trying to do. Suppose that you want to test the rows for some value of X and return Y accordingly.
private Sub Whatever(XInVBA AS XType,YInVBA AS YType)
dim Finder as String
dim YHolder as RecordSet
Finder="SELECT Y FROM TheTable WHERE x=" & XInVBA & ";"
Set YHolder=CurrentDB().OpenRecordSet(Finder)
YHolder.MoveFirst
YInVBA=YHolder.Fields(0)
end sub

This discussion is closed to new replies.