Solved

How to create a local Collection in Access 2000 form code

Posted on 2001-06-14
8
145 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
[X]
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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

696 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