How to Loop to get fields in a record

  • Thread starter Thread starter Kirk Groome
  • Start date Start date
K

Kirk Groome

Hi All,
I have a record with fields 11 throught 150 and I want to loop throught the
fields and put them in an array. What is the correct way to do this.

code sample

.... Open record set and find a record

For Rooms = 11 To 14
aRoom(Rooms, AddDays) = rstRoomAvailability![(rooms)] '
should be the same thing as btest = rstRoomAvailability![11] PROBLEM
LINE
' aRoom(11) = rstRoomAvailability![11]
' aRoom(12) = rstRoomAvailability![12]
' aRoom(13) = rstRoomAvailability![13]
' aRoom(14) = rstRoomAvailability![14]
Next


Thanks Kirk
 
You need to use rstRoomAvailability.Fields(Rooms) rather than
rstRoomAvailability![(Rooms)]
 
What do you mean by fields 11 through 150? Do you have 150+ fields in a
table?

Sidenote: You'll find that there's not a 'correct' or 'best' way to do
anything.
 
Thanks that did the trick. I need to convert the number to a string to get
the right field .

Thanks
Kirk

Douglas J. Steele said:
You need to use rstRoomAvailability.Fields(Rooms) rather than
rstRoomAvailability![(Rooms)]

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Kirk Groome said:
Hi All,
I have a record with fields 11 throught 150 and I want to loop throught
the fields and put them in an array. What is the correct way to do this.

code sample

... Open record set and find a record

For Rooms = 11 To 14
aRoom(Rooms, AddDays) = rstRoomAvailability![(rooms)] '
should be the same thing as btest = rstRoomAvailability![11] PROBLEM
LINE
' aRoom(11) = rstRoomAvailability![11]
' aRoom(12) = rstRoomAvailability![12]
' aRoom(13) = rstRoomAvailability![13]
' aRoom(14) = rstRoomAvailability![14]
Next


Thanks Kirk
 
Back
Top