Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / October 2007

Tip: Looking for answers? Try searching our database.

My Forms Collection

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joe Cletcher - 09 Oct 2007 19:03 GMT
I want to create a collection of forms that maintains the state of the form.
I plan to add the form to the collection, then close the form before I move
onto the next form selected by the user. I think I can do that. However, when
I want to return to a form at it's saved state in the collection, I don't
know how to open and show the form.

the following doesn't work
docmd.opeform "form name string"

docmd.openform mycollection(3) won't work

can I

set aform = mycollection(3)
aform.visible

I've never been able to do the above in VBA. No  problem in VB.NET
George Nicholson - 09 Oct 2007 19:46 GMT
What *exactly* are you adding to the collection, an access object, a form
object or the form name?

If form object:
   docmd.openform mycollection(3).Name
that should work as long as the form is open, but makes little sense if it's
open...
"A Form object is a member of the Forms collection, which is a collection of
all currently open forms."
My guess is that if you are adding a Form object to a collection and then
close the form, your collection now contains Nothing.

If an Access object (from the AllForms collection)
   docmd.openform mycollection(3).Name
should work.

If form name:
   docmd.openform mycollection(3)
should work

> set aform = mycollection(3)
> aform.visible

As above: if aform is a Form object, and open, that should work. If it
isn't, it won't. One major difference between VB forms and Access is how
they can be opened. I have a vague recollection that setting a VB form's
Visible property automatically invoked Show/Load, if necessary (or something
like that). Whether that is the case or not, Access forms won't behave that
way, you have to explicitly open them, no shortcuts.

HTH,

>I want to create a collection of forms that maintains the state of the
>form.
[quoted text clipped - 16 lines]
>
> I've never been able to do the above in VBA. No  problem in VB.NET
Joe Cletcher - 10 Oct 2007 01:46 GMT
I plan on putting an Access form object in the collection. The real problem
is I can't seem to open a second copy of a form in Access. My form displays
parts (parent parts) that may or may not be made up of other piece parts. The
piece parts are shown in a sub-form--there are several sub-forms. I want to
be able to double-click on a piece part and show it as the parent part with
any of its piece parts. I can do this, but as soon as I do the form that
displays the original parent part is replaced with the new parent (elevated
piece part).

I was hoping that in the "Before Close" event that I could store the
original parent form object in a collection and then let the form continue to
close; then let Access replace the original parent form with the elevated
piece part to parent form.

Is all that clear as mud.

My choice may be to create a class and then a collection of this class with
the information needed to open the original form in it's initial state. I
would like to create a stack of the forms opened by the user, let them choose
any form to return to and continue from there. Methods for this "stack" class
would include "Pop, "Push", "Top" and "Empty" which are standard stack
methods. Of course, that may require a second class to hold a collection with
the stack methods. Rather that program all those "classes", a collection has
the methods (different names but same functionality) and would save a great
deal of effort trying to figure out how to write a "Collection" class in VBA.

> What *exactly* are you adding to the collection, an access object, a form
> object or the form name?
[quoted text clipped - 48 lines]
> >
> > I've never been able to do the above in VBA. No  problem in VB.NET
Alex Dybenko - 09 Oct 2007 19:47 GMT
Hi,
access already has Forms collection, which contains all loaded forms,
perhaps you can use it?

forms("MyForm").Visible=true

anyway - you can't use access forms the same way as vb or .net forms

Signature

Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com

>I want to create a collection of forms that maintains the state of the
>form.
[quoted text clipped - 16 lines]
>
> I've never been able to do the above in VBA. No  problem in VB.NET
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.