[AccessD] DependentObjects class

Jürgen Welz jwelz at hotmail.com
Thu Mar 11 00:56:53 CST 2004


I don't like using control tags to hold temporary data and they lack 
persistence as well, so I'd append a property to the each form containing 
the combos.

When one updated, it would set its own property to the current time.  If the 
dependent control property is older by more than 3 seconds (how often are 
users going to change two separate combo entries more quickly than 3 seconds 
apart?), requery it and in either event, update the dependant's property.  
I'd use a property that used the name of the control with a suffix like 
"Time".

I use a form property in the name of each control to hold a security long of 
paired bit flags (edit, add, read, hidden).  To append a date property:

Sub ctlprop()
Dim prp As Property

            Set prp = 
CurrentDb.Containers("forms")"frm1").CreateProperty("cboCityTime", dbDate, 
Now)
            CurrentDb.Containers("forms")("frm1").Properties.Append prp
            CurrentDb.Containers("forms")("frm1).Properties.Refresh
End Sub

Once the property has been created, your code can set and read it.

           CurrentDb.Containers("forms")("frm1").Properties("cboCityTime") = 
Now
           dteVariable = 
CurrentDb.Containers("forms")("frm1").Properties("cboCityTime")

You can create a reference as in the procedure in which it was created and 
just set the variable:

Dim prp As Property
Dim db As Database
Set db = CurrentDb

Set prp = db.Containers("forms").Documents(1).Properties("cboCityTime")
MsgBox prp

Ciao
Jürgen Welz
Edmonton, Alberta
jwelz at hotmail.com





>From: "John W. Colby" <jwcolby at colbyconsulting.com>
>
>I am working on a dependentobjects class, i.e. a class with a collection
>which holds objects (classes) where the control or form is dependent on the
>current control.  Combo A changes.  Combo B uses Combo A to filter itself.
>Combo B is "dependent" on combo A and must be requeried whenever Combo A
>changes.
>
>There is a case where two combos on a form may display data from the same
>table.  For example two combos both display cities from the cities lookup
>table.  If Combo A NotInList adds a new city. Combo B needs to requery in
>order to display that new city if necessary.  However if Combo B adds the
>city, then Combo A needs to requery.
>
>Obviously if we add combo A to combo B's DependentObject collection and we
>add Combo B to Combo A's dependent object collection, then we start an
>endless loop where A requeries B which requeries A which requeries B...
>
>This is a case where I programmed a solution working but it was ugly.  How
>would you solve this problem?
>
>John W. Colby
>www.ColbyConsulting.com

_________________________________________________________________
MSN Premium helps eliminate e-mail viruses. Get 2 months FREE*  
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines




More information about the AccessD mailing list