Solved

How to create a local Collection in Access 2000 form code

Posted on 2001-06-14
8
141 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

919 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now