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!

Pass data from form and then close

Status
Not open for further replies.

aw23

Programmer
Nov 26, 2003
544
IL
I have a form where the user selects a button to export data. A form opens where there are two listboxes and the user selects all the fields he wants exported and moves them to the second listbox. Then I loop through the second listbox and store all the data in an array. I then close the form and continue with the export. However I need to pass the array to my main form? (The second is not a subform, just a regular form) How can I do this?

Thanks
 
In the main form declare a global variable.
Code:
Dim arrExportData as Variant

Then create a custom property for the main form so you can set the data from the second form
Code:
Public Property Let ExportData(ByVal vNewValue As Variant)
   arrExportData = vNewValue
End Property

This should allow you to move the data array from the second form to the main form by doing the following in the second form
Code:
[i]MainForm[/i].ExportData([i]data_array_on_2nd_form[/i])

MainForm is the name of your main form
data_array_on_2nd_form is the variable on the second form that is the array.

If you get an Error when you call the property, you may need to ReDim arrExportData in the Let statement before you can assign new data to it.

Hope this helps.
 
Thanks, I received the following error when I call the function
Forms("company").ExportData (ArrFields)


Wrong number of arguments or invalid property assignment.
I tried rediming and I still receive the error.

Thanks
 

the easiest way to pass variables from 1 form to another is to created a module and add this code to it:

' ARRAY
Public varData(9) As Variant '0-9 for 10 fields

now you can reference this array from any where.


form1
varData(1) = "test1"

form2
text0 = varData(1)
 
Thanks so much. That worked, great idea.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top