Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loop through fields 1

Status
Not open for further replies.

turnerk200

Programmer
Mar 9, 2004
20
0
0
AU
Hello all,
I have a situation where i am trying to check a recordset, the recordset will only have 1 record in it and I need to loop through say 12 fields and check that at least one of them has the value "-1" in it. Is there an easy and quick way of refering to the fields as a set and looping through them? Hope this makes sense.
kt
 
Dim arr(11) As String
Dim i as Integer
Dim blnResult As Boolean

arr(0) = Field1Name
arr(1) = Field2Name....

arr(11) = Field12Name

For i = 0 To 11
If rst.Fields(arr(i)) = -1 Then
blnResult = True
End if
Next

Adapt to your needs.
 
Thanks Craig0201 for your post, however, some of the fields the code you have given shows an error when trying to asign a null value to an array. Am I missing something?
Thanks again for your help.
kt
 
Hi Craig0201 - disregard my previous post, have got it working - thank you very much for your help and have a great day.
kt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top