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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array to Recordset 1

Status
Not open for further replies.

danvlas

Programmer
Jul 30, 2002
2,446
RO
Has anyone any idea of how to use (or convert) an array as a recordset? I need to populate a form with the lines from an array.
The problem is that the array is dinamically ReDimmed and there is no known limit of its upper size, so I can't just hide/display used controls.

At this moment, I'm writing the information from the array to a temporary table, but I'd like to avoid this, if possible.

Thanks,
Dan
[bigears]
 
When you say the Array is redimed and its size is not known can you not just use the Ubound(array) to find out how many elements are in it?
There are two ways to write error-free programs; only the third one works.
 
I use UBound all right, but this is not the point. I can use the elements of the array to populate unbound textboxes, but there are limits for the number of controls on a form. That is why I wonder how to 'fake' a recordset from an array data, without storing such data in a table...


Thanx anyway

Dan
[thumbsup2]
 
Oh, right, OK, sorry, misunderstood the problem. There are two ways to write error-free programs; only the third one works.
 
I have done similar to this by creating an array of user type eg.

Public Type Person_type
FirstName As String
LastName As String
Age As Integer
End Type

Sub mPeople()
Dim aPeople(10) As Person_type

aPeople(1).FirstName = "John"
aPeople(1).LastName = "Smith"
aPeople(1).Age = 10

End Sub

If the array is global you can use it similar to a record set..
ie. move backwards - forwards etc, if you maintain a pointer to the current element.
There are two ways to write error-free programs; only the third one works.
 
And how do you set the form's recordsource to the elements?
My form should behave like a ReadOnly form (I don't need to add, edit or delete data, but the number of rows is absolutely random).
It's easier in a report, but I really need it in a form (need the Click, DblClick and Current events...)

Dan
 
I use next & previous buttons on an unbound form and load the text boxes with the appropriate values, the downside of this is obviously you can only see one record at a time.
On one form where I want to see all the records I use a function which dynamically loads the records into a list box, and load the form after the selection is made in the list box.
There are two ways to write error-free programs; only the third one works.
 
That's it!
I can live with one record at a time...
One star from me for this one LOL
Thanx

Dan
Now I'm going to [pipe]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top