Solved

How to create a local Collection in Access 2000 form code

Posted on 2001-06-14
8
140 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 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

15 Experts available now in Live!

Get 1:1 Help Now