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

AddNew Loop with a an Array

Status
Not open for further replies.

bbrendan

IS-IT--Management
Joined
Dec 13, 2001
Messages
109
Location
GB
Hi,

I have an array of text boxes (50 of them) I would like to, instead of having to type each one in loop through them:

My current code is this:

With ObjRecMaster
.AddNew
.Fields(0) = txtFields(0).Text
.Fields(1) = txtFields(1).Text
............
.update
End with

How could I just get loop through each .field and txtfield instead of typing up 50+ lines of code???

thanks
brendan

 
You can try this,

Code:
Dim i as integer

With ObjRecMaster
  .AddNew
  For i = 0 to 50 'or what ever your max is.
    .Fields(i).Value = txtFields(i).Text
  Next i
  .update
End with

You still need to make sure that you are placing the correct data in the correct field.


zemp
 
thanks zemp.

Your a star!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top