Array shuffler (1 Viewer)

Ron_dK

Cool bop aficionado
Local time
Today, 20:20
Joined
Sep 5, 2002
Messages
2,141
I have played around with the example from Adam, and wondered how one can make the data output avialable in a form.

I have tried the on click event on a label, but that doesn't work.

I would appreciate any pointers.

I used the 2003 version in this post :


http://www.access-programmers.co.uk/forums/showthread.php?t=142130
 

Guus2005

AWF VIP
Local time
Today, 20:20
Joined
Jun 26, 2007
Messages
2,642
How and where do you want to use the arrays?
If you dimension the Arrays globally they are available throughout you application.
On the onload event of the form you can fill the arrays.
 

ajetrumpet

Banned
Local time
Today, 13:20
Joined
Jun 22, 2007
Messages
5,638
wondered how one can make the data output avialable in a form.

I have tried the on click event on a label, but that doesn't work.
Rak,

What are you trying to do with it? What do you mean, "available in a form"? Like, displaying the data on a form that has a data source (like a table as a recordsource)? E.G. - in a record-style format, but using a form for display purposes?
 

Ron_dK

Cool bop aficionado
Local time
Today, 20:20
Joined
Sep 5, 2002
Messages
2,141
Guus,

I would like to see the values generated in the ( VB) immediate window in a field on a form.
I tried to call the function on the on load event, but to no avail.
Any suggestions ?

Bedankt,
Ron
 

Moniker

VBA Pro
Local time
Today, 13:20
Joined
Dec 21, 2006
Messages
1,567
Unless you set a control for each variable returned, you're SOL here. You could output it all to a memo field in a form, but it depends on what you're trying to do with the data as to how appropriate that might be.

Also, Collections are far easier than Arrays to deal with. Just an FYI.
 

Ron_dK

Cool bop aficionado
Local time
Today, 20:20
Joined
Sep 5, 2002
Messages
2,141
Like, displaying the data on a form that has a data source (like a table as a recordsource)? E.G. - in a record-style format, but using a form for display purposes?

That's exactly what I wanted Adam.

Moniker said:
Unless you set a control for each variable returned, you're SOL here. You could output it all to a memo field in a form, but it depends on what you're trying to do with the data as to how appropriate that might be.

My intend was to use the generated arrays for test purposes. No rocket sience there, but just wanted to have them being populated in a memo field.

As you can see, my knowledge of VBA is rather restricted, but willing to learn,
and I figured by using Adam's Dbase, I might improve my knowledge.

Collections are far easier than Arrays to deal with

What collection are you refering to ?

Thanks, Ron
 

Moniker

VBA Pro
Local time
Today, 13:20
Joined
Dec 21, 2006
Messages
1,567
Type the word Collection into the Immediate Window (press Ctrl-G to get that) then highlight it and press F1. A collection is just like an array but easier to manage. For example, if you have an one-dimension array of five entries (0-4), and you delete entry 2, you still have five array entries, just an empty one in the middle. If you have a collection of 5 (1-5, as collections are one-based and arrays are zero-based), deleting object 3 reconfigures the collection to be 4, therefore filling the gap, as it were.

Additionally, arrays are all of one datatype where collections can be anything in each entry (integer, text, etc.) and therefore are less limited. Additionally, you do not dimension the size of a collection in the same way you may do an array. The collection is like an accordion -- it expands and contracts as needed. The array is a fixed size and fixed datatype, limiting its usefulness.

Arrays are not entirely bad, but the collection is the better choice most of the time. Do a little research on these if you really think they are right for you.

As for a memo, just add a texbox to your form and output to that instead of the Debug.Print.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 19:20
Joined
Sep 12, 2006
Messages
15,696
typically you would use an array for some internal processing

the point about access is that it binds data controls to a dataset (this may not be 100% accurate technically) but I dont think an array can serve as a dataset for these purposes

if you are trying to use an array to test a database function then you are probably struggling

if you want to use an array to simulate some processing, then write a function to dereference your array into a string for display purposes, and then assign the string to a textbox value
 

ajetrumpet

Banned
Local time
Today, 13:20
Joined
Jun 22, 2007
Messages
5,638
That's exactly what I wanted Adam.
Well, if that's exactly what you want, then I would say you are just trying to generate a randomized resultset from the array that you've built. Are you? If that's what you want, posts 30 & 31 in this thread might be of interest to you. My sample threw the array into a table, then displayed a form off of that. Wayne's example used a stored query.
I dont think an array can serve as a dataset for these purposes
I think Gemma has hit the nail on the head here. I agree with this, and that certainly limits your options with the array!

This makes sense to me, because the array is a "non-materialized" entity, and something like a table is a "materialized object" (if that makes any sense).

And thanks to Moniker too, I learned something ELSE from him (after learning how to print a piece of paper!) :)
 
Last edited:

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 19:20
Joined
Sep 12, 2006
Messages
15,696
moniker, i played with collections for a while, but i just couldnt get manage the indexes in the way i wanted

now if vba had a pointer type it would be easy ....

having said that, i struggle to see just how necessary collections are for database processing
 

Moniker

VBA Pro
Local time
Today, 13:20
Joined
Dec 21, 2006
Messages
1,567
The code I used shown here displays a good use of a collection.

Basically, collections are great for holding temporary data when you are not sure how much temporary data you are going to get. Collections will also allow multiple data types, which is a bonus if you're not sure what type(s) of data you're getting. In my code, I used a collection to hold the names of the primary key field(s) from various tables. One table could have one field as the key, while another table could have four fields making up the primary key. In that case, a collection was very useful.

There are other examples to be found, but I wanted to provide a real world one to show their usefulness. I'm not going to use a collection in everything I write -- they're very specific in when they are useful -- but I'm glad I know they exist and are available if the right situation comes up.
 

Ron_dK

Cool bop aficionado
Local time
Today, 20:20
Joined
Sep 5, 2002
Messages
2,141
If that's what you want, posts 30 & 31 in this thread might be of interest to you.

That's a great example , you 've got there and pretty much of what I had in mind.
I will play with this one and see if I can adapt that to my needs.

Thanks all for the input.

If I have some more time, I will dive into the collections thing.

Cheers, Ron
 

murphybridget

Member
Local time
Tomorrow, 02:20
Joined
Dec 5, 2023
Messages
77
Type the word Collection into the Immediate Window (press Ctrl-G to get that) then highlight it and press F1. A collection is just like an array but easier to manage. For example, if you have an one-dimension array of five entries (0-4), and you delete entry 2, you still have five array entries, just an empty one in the middle. If you have a collection of 5 (1-5, as collections are one-based and arrays are zero-based), deleting object 3 reconfigures the collection to be 4, therefore filling the gap, as it were.

Additionally, arrays are all of one datatype where collections can be anything in each entry (integer, text, etc.) and therefore are less limited. Additionally, you do not dimension the size of a collection in the same way you may do an array. The collection is like an accordion -- it expands and contracts as needed. The array is a fixed size and fixed datatype, limiting its usefulness.

Arrays are not entirely bad, but the collection is the better choice most of the time. Do a little research on these if you really think they are right for you.

As for a memo, just add a texbox to your form and output to that instead of the Debug.Print.
I love the analogy of collections being like an accordion, expanding and contracting as needed! It's a great way to visualize the flexibility they offer compared to arrays.
 

Users who are viewing this thread

Top Bottom