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!

pass an array from form to form?

Status
Not open for further replies.

xq

Programmer
Jun 26, 2002
106
NL
this array contains a set of ID number where those records will be updated and it is result from user input on form A, and updating things will be done on form B, therefore i have to pass that array from form A to form B, how can i do that?
really appreciate for any help!
 
You could declare the array as Public, fill in the elements through one form and use the values in another form...

HTH

Dan
[pipe]
 
can i? but when i run the program, there is an error says 'sub or function not defined'.
 
In a module, dim your dynamic array:
Public MyArray()

In the first form, load the array with data

For i = 0 To NumberOfIDs - 1
Redim Preserve MyArray(i) 'keep previously stored data
'insert code to calculate the ID you want to store
MyArray(i) = CalculatedID
Next

In the second form (the array is full now):

For i = 0 To UBound(MyArray,1)
Whatever = MyArray(i)
Next i
Erase MyArray 'when you don't need it anymore

This should work.

Sub Or Function not defined: check your spelling. And you could post the piece of code here, otherwise we're talking about weather...and it's really cloudy/rainy here...

HTH

Dan
[pipe]
 
aha! got it, dim array in the module, thanks million! learn a lot!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top