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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New to VBA - for loops

Status
Not open for further replies.

lopster10

Technical User
Jan 26, 2009
17
DE

Hi guys,

I've literally starting learning VBA a few days ago so plz keep that in mind:)

I have learnt some of the basics, but im just looking at DAO.
In the following statement, what is the purpose of the - 1 ?? Why is this needed?

For i = 0 to db.TableDefs(0).Fields.Count - 1
Debug.print db.TableDefs(0).Fields(i).Name
Next

Any help appreciated.
 
The Fields Collection may be considered as an an array with option base 0, ie the 1st index is 0 ant thus the last index is the the total number of elements [!]- 1[/!]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Ahh thank you very much, I wasnt thinking about how the individual fields would be returned, my bad.

Regards

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top