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 sizbut 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 to a form 1

Status
Not open for further replies.

bozic12

MIS
Jan 23, 2003
48
US
Hi,
I would like to pass an array that is declared and populated in user form "Workholdings" to another user form, "WorkholdingChoices". You can't declare arrays publicly in object level modules, and I tried declaring it publicly in the project module, but when i redim it in the form code, it says the array isn't declared. When the user clicks a button in "Workholdings", I just have the code, WorkholdingChoices.show, I don't know how to pass any parameter to this form, let alone an array. Thanks for any help!!
 
If you're just trying to pass information to the form, why do you need to redim it in the userform code? If you tell us more about exactly what you're trying to accomplish, I'm sure we'll come up with a workaround.
Rob
[flowerface]
 
ok, this is fairly difficult to explain, so please bear with me. I have 3 user forms: Workholdings, WorkholdingChoices, and Accessories. The initial form is workholdings. The user chooses two options from comboboxes which then populates a Brands listbox. It also populates an array, called Brands, which is declared as Brands(3, 20). I have it defined with 3 dimensions because each brand has 3 attribtes, which based on selections, will be shown on different forms. For instance, if the 2nd dimension is brand names, when a brand is chosen, the 1st dimension values for that brand are shown in a listbox in the WorkholdingChoices form. I don't need to pass the array yet because I do this in the BrandsCombo_AfterUpdate() private sub. But, when the WorkholdingChoices comes up, and the user makes a choice from this list box, I need the array in this user form so that I can use the 3rd dimension of the array with the chosen options to populate a listbox in the Accessories form. I guess I could just paste the array to a worksheet, then populate an array in the WorkholdingChoices form from the worksheet, but if I could pass the array from the Workholdings to the WorkholdingChoices form, that would be more efficient. I hope you can understand what I'm trying to do here from my description, but it's fairly complicated and it would take a book for me to describe exactly what is going on.
 
I'd do away with trying to redim. Declare your array to the maximum required size as a public in a regular code module, and have as another public an integer which keeps track of how many brands are loaded into the array, e.g.

public brands(3,20) as string
public brandscount as integer

Now you can populate your array and set the brandscount variable in one form, and use the information in the other forms. Make sense?
Rob
[flowerface]
 
Rob, that did work. I could have sworn that was the first thing I tried to do, it is the most logical thing to do. I may have just had my array names or declarations incorrect. Anyway, thank you for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top