Size of array elements?

  • Thread starter Thread starter Margaret Bartley
  • Start date Start date
M

Margaret Bartley

I have a two-dimensional array that I redim in my code:

ReDim arRecs(FCnt, 8)


This gives me 8 data elements for every Farm (FCnt). There are many
different types of data in this array; I'm having trouble with the string
elements.

Each element is truncated at 50 characters. Is there a way to force this
array to give me 255 characters for each element that gets used as a string?
 
Hi Margaret,

Assuming you've declared arRecs as an array of variant, e.g.

Dim arRecs() As Array

there seems no obvious reason why you shouldn't be able to store as much
as you like in the strings (subject of course to the usual limitations
such as available virtual memory). Is it possible that you're retrieving
strings from 50-character text fields?

But a two-dimensional array is probably not the best place to store
structured data in VBA, and still less in Access, where the first choice
is normally to store data in a table.

If you want to get all the data into memory, you could define a custom
type to hold the fields you need, e.g.

Type tFarm
Name As String
County As String
Area As Single
...
End Type

and then have an array of tFarm. Or better yet, define a Farm class and
construct a Collection of Farm objects.
 
Back
Top