Link to home
Start Free TrialLog in
Avatar of zero303
zero303

asked on

Accessing another forms variables... easy on again lol

I have a form called frmMaintainCustomerDetails which has a multi-dimensional array Customer(100, 13).

Im in a form called frmMaintainPropertyDetails and i want to access Customer(i, 0) in the form above... how???

I told the guys at uni we should have done our prototype in Java!!!!


Gar
Avatar of VBtom
VBtom

Easy...
Declare Customer with Public (instead of Dim) in frmMaintainCustomerDetails

Then, in frmMaintainPropertyDetails you can use frmMaintainCustomerDetails.Customers(i, 0)

That's all, hope this helps you.
Actually, you can't define arrays as project level variables.
In frmMaintainCustomerDetails add this code

Public Property Get Customer(ByVal Index1 as integer, ByVal Index2 as integer) as String
   Customer = Customers(Index1,Index2)
End Property

Public Property Let Customer(ByVal Index1 as integer, ByVal Index2 as integer, Byval StrCustomer as String)
   Customers(Index1,Index2) = StrCustomer
End Property

I think that is what you require.

ASKER CERTIFIED SOLUTION
Avatar of zero303
zero303

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi.

I was wrong indeed, you cannot declare an array public in a form.
But you can in a module, so an easier solution is:
add a module and declare Customer in the module (not in frmMaintainCustomerDetails):
Public Customer(100, 13) As String

Then, you can give it values in frmMaintainCustomerDetails  and access them in frmMaintainPropertyDetails by just using Customer(..., ...)
Hi zero303,
This old question (QID 20562780) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.