Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to create a local Collection in Access 2000 form code

Posted on 2001-06-14
8
144 Views
Last Modified: 2010-05-02
In an Access 2000 Form,
I've got a number of text fields on the form that I want to either hide or unhide (in groups) depending on use selection. What I thought I would do is:
- Declare some collections for the normal grouping of these fields and add the fields to the appropriate collections
- If I need to .visible=false any of the groups I could use a :
           For each x in coll
                    .visible=false
          next x
 
  To hide/unhide the groups.

MY PROBLEM IS:
I cannot find a way to add the textfields to the collections without having to invoke a procedure (because I want them to be always part of the collection, not just after I run a procedure (because I may not always run a procedure before needing the collection)).

How do I add elements to a collection object outside the scope of any procedure?
0
Comment
Question by:Sparrow1
  • 5
  • 3
8 Comments
 
LVL 4

Expert Comment

by:beckingh
ID: 6192208
Declare the Collection with module/global scope.  So outside of any procedure.

Then in your form_load event add the fields to the collection.
0
 
LVL 4

Expert Comment

by:beckingh
ID: 6192223
Form1.frm:

'****************************
Public moColl as Collection

Private Sub Form_Load()
  set moColl = new Collection

  moColl.Add Text1

End Sub

Private Sub Form_Unload()
  Set moColl = Nothing

End Sub
0
 
LVL 4

Expert Comment

by:beckingh
ID: 6192224
Form1.frm:

'****************************
Public moColl as Collection

Private Sub Form_Load()
  set moColl = new Collection

  moColl.Add Text1

End Sub

Private Sub Form_Unload()
  Set moColl = Nothing

End Sub
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:Sparrow1
ID: 6192233
So I have to add the fields to the collection inside of a method? I can't do like a static add or such?
0
 

Author Comment

by:Sparrow1
ID: 6192297
Also, if I have to use procedures, should I use Load/Unload, Activate/DeActivate or Open/Close?
0
 
LVL 4

Accepted Solution

by:
beckingh earned 150 total points
ID: 6192314
I'd use Load/Unload.  Guaranteed to only happen once, and before and after (respectively) most everything else.

No way to do a static add to a collection.

But this is pretty standard coding practice.  Write yourself a function to do the add, and call it from the load event.
0
 

Author Comment

by:Sparrow1
ID: 6192564
Thank you very much for your prompt response and continued support. Your answers were exactly what I was looking for.
0
 
LVL 4

Expert Comment

by:beckingh
ID: 6193060
No trouble at all.  Glad I could help.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question