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

Update an array

Status
Not open for further replies.

sborny

Technical User
Jun 29, 2001
157
0
0
GB
Hi,

I have an app that downloads a CSV file from the net and loads the record data into an array. There is a form that then displys the data and allows the user to go back & forth between records.

When a command button is pressed the form is set to display the first record and then updates a database.

The user has requested that they be able to change the data that is displyed on the form if it is incorrect. This is no problem, but when the command button is pressed and the form goes back to the first record it populates the textboxes with the data in the array and not what was changed. Is there a way to update the data in an array if the value in a text box is changed manually, so that the changed data is what is put into the database.

I hope this makes sense.

Thanks

S.

Everything has an answer, it's just knowing the right question to ask. !!!!
 
declare the array dynamically, and redim it whenever you want to reload, like so:

Code:
Dim MyArray() as String

Private Sub Do_Reload()
Redim MyArray(size) 'you should replace size with the number of records
(pupulate the array here)
End Sub

You should keep the array as small as possible, so redim it to the size of the records. To loop through the records, use the UBound function to see how big the array is.

Brian
 
Also have a look at ReDim Preserve. Allows you to expand on the array without losing the earlier data in it.
 
Forgot to mention Preserve :) Good point ZOR. not using preserve erases the entire array.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top