Advertisement

07.17.2008 at 07:02AM PDT, ID: 23573215
[x]
Attachment Details

Array of Class in Access

Asked by jdhackett in Access Coding/Macros, Microsoft ADP, Access Forms

Tags: Access VBA

Access ADP, Office 2003.
I have clsVehicle which is my own class for a vehicle.
I want to fill an array of these vehicles.
Dim arrFleet() As clsFleet

So in my code, I count how many vehicles there are. Then I redim the array to that size.
ReDim arrFleet(iVehicle_Count)
If I then try
Debug.Print arrFleet(1).RegNo
I will get an error:
"Object variable or With block variable not set"

Now, I can around this with:
   For iLoop = 0 To (iVehicle_Count - 1)
      Set arrFleet(iLoop) = New clsFleet
   Next

But this seems a bit awkard. Is there a better way?
Something I should put in my class, or another way to declare the array?
Thanks
Start Free Trial
 
Loading Advertisement...
 
[+][-]07.17.2008 at 08:10AM PDT, ID: 22026284

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Access Coding/Macros, Microsoft ADP, Access Forms
Tags: Access VBA
Sign Up Now!
Solution Provided By: vadimrapp1
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628