[AccessD] I used to be young and stupid

John Colby jwcolby at gmail.com
Mon Jan 17 07:42:32 CST 2022


The problem with this approach is that often combos are dependent on each
other, and other objects as well such as forms depending on combos.  For
example cboPolicy depends on cboPolicyHolder which depends on cboInsurer
etc.  The combos need to be requeried in a specific order so that the
'dependent' combos can select the correct data.

My framework addressed this by using a wrapper class for each object to
have a collection to hold pointers to dependent objects. Then in the form's
CBF OnOpen, program which objects depend on which objects.  It is quite
common for example for forms to depend on combos as well.

When a combo requeries, that combo knows that objects X and Y 'depend' on
it and so if the user selects something in that combo, that combo's wrapper
class sinks the AfterUpdate and iterates through the colDependentObjects,
requerying any objects in the collection, in the order found.

It takes a little thinking about but it works a treat.

On Mon, Jan 17, 2022 at 8:05 AM Arthur Fuller <fuller.artful at gmail.com>
wrote:

> Thanks, Stuart: useful and reusable
>
> On Sun, Jan 16, 2022 at 5:51 PM Stuart McLachlan <stuart at lexacorp.com.pg>
> wrote:
>
> > Not more efficient, but probably cleaner and generic.
> > A public funrction in a module.
> >
> > Function RequeryComboboxes(frm As Form) As Long
> >     Dim ctl As Control
> >     For Each ctl In frm.Controls
> >         If ctl.ControlType = acComboBox Then
> >             ctl.Requery
> >         End If
> >     Next
> > End Function
> >
> > Call from inside the form:
> > RequeryComboBoxes Me
> > or from elsewhere
> > RequeryComboxes Froms("frmSomeformName")
> >
> >
> >
> >
> > On 17 Jan 2022 at 10:24, Paul Wolstenholme wrote:
> >
> > > My personal preference would be to write a public function in the form
> > > that requeries each of the combo boxes using Me.CompanyID_cmbx.Requery
> > > ...
> > >
> > > I can call the function from another form if I need to, but I find it
> > > best to keep those calls to higher level concepts (refresh form data)
> > > rather than calling for each individual control to be updated.
> > >
> > > In this way I can change details within the form without too much
> > > concern for how other forms relate to it.  As long as the public
> > > function still works, the interaction between the forms will probably
> > > be unaffected by my changes.
> > >
> > > Paul
> > >
> > >
> > > On Sun, 16 Jan 2022 at 15:12, Rocky Smolin <rockysmolin2 at gmail.com>
> > > wrote:
> > >
> > > > Additionally, "a good program is one that works". No one ever reads
> > > > your code.
> > > >
> > > > r
> > > >
> > > > On Sat, Jan 15, 2022 at 2:47 PM Arthur Fuller
> > > > <fuller.artful at gmail.com> wrote:
> > > >
> > > > > One thing has changed: now I'm old.
> > > > >
> > > > > I'm working on an app that I began 17 years ago and have revised
> > > > > several times as legal requirements, functional requirements and
> > > > > UI fashions have evolved. while wandering through the ancient
> > > > > code, I came across this. <snippet> If
> > > > > FormIsOpen("AssessID_Data_LC_Frm") Then
> > > > >     Forms!AssessID_Data_LC_frm!CompanyID_cmbx.Requery
> > > > >     Forms!AssessID_Data_LC_frm!ProjectID_cmbx.Requery
> > > > >     Forms!AssessID_Data_LC_frm!CompanyID.Requery
> > > > >     Forms!AssessID_Data_LC_frm!ProjectID.Requery
> > > > >     Forms!AssessID_Data_LC_frm!LocationID.Requery
> > > > > End If
> > > > > </snippet>
> > > > >
> > > > > I wonder whether there is a more efficient way to do this, such as
> > > > setting
> > > > > a reference to the form, and for that matter just re-querying the
> > > > > form instead of its controls individually.
> > > > >
> > > > > --
> > > > > Arthur
> > > > > --
> > > > > AccessD mailing list
> > > > > AccessD at databaseadvisors.com
> > > > > https://databaseadvisors.com/mailman/listinfo/accessd
> > > > > Website: http://www.databaseadvisors.com
> > > > >
> > > > --
> > > > AccessD mailing list
> > > > AccessD at databaseadvisors.com
> > > > https://databaseadvisors.com/mailman/listinfo/accessd
> > > > Website: http://www.databaseadvisors.com
> > > >
> > > --
> > > AccessD mailing list
> > > AccessD at databaseadvisors.com
> > > https://databaseadvisors.com/mailman/listinfo/accessd
> > > Website: http://www.databaseadvisors.com
> > >
> >
> >
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > https://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
>
>
> --
> Arthur
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>


-- 
John W. Colby
Colby Consulting


More information about the AccessD mailing list