[AccessD] Create/Hide Buttons on Form?

Jurgen Welz jwelz at hotmail.com
Thu Feb 23 18:09:34 CST 2006


Charlotte:

Assuming a non-continuous form, of course there are limiitations, but in my 
experience using functions in place of 'Event Procedure' is no more limiting 
than events with VB6 Control Arrays.  In VB, your code is differentiated on 
an index.  With Access, it is based on an attribute of the only unique  
possible active control experiencing a user interaction.  The attribute can 
be the control name or caption or any other attribute accessible through the 
control's properties, directly accessible through the reference to 
Screen.ActiveControl.

I've also had success with creating an array of controls in Access:

Dim cmdButton() As CommandButton

and setting the object variables in the form open event via iteration.  
Typically, the click event checks the control name against that in the array 
of controls and works its magic from there.  In some cases it is convenient 
to arrange a form recordset so that the field order for the first 'n' fields 
corresponds to the 'control array' index.  Sure it is somewhat limiting and 
it may become more difficult to make other kinds of changes that won't be 
impacted by restrictions.

This approach is analagous to using a continuous subform, each with one or 
more buttons depending on the desired action(s).  It is simple to disguise 
the subform by losing record selectors, navigation buttons and dividing 
lines and have it appear like a conventional form.  It takes a bit of work 
with the form cycle and tab order to make it transparent, but if the code 
can be made to work from a control array, you should be able to make an 
inteterminate number of subforms work by acting on the record that becomes 
current upon the click.

Again, I have not looked at earlier posts so am not certain as to the degree 
of complexity or whether the data design is amenable to this approach.

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





>From: "Charlotte Foust" <cfoust at infostatsystems.com>
>
>True, but that limits your handling in the extreme.
>
>Charlotte
>
>
>-----Original Message-----
>From: accessd-bounces at databaseadvisors.com 
>[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Jurgen Welz
>Sent: Thursday, February 23, 2006 2:29 PM
>To: accessd at databaseadvisors.com
>Subject: Re: [AccessD] Create/Hide Buttons on Form?
>
>
>You can use a function in the property sheet so you should be able to hook
>up events by specifying a function in the property sheet.  To operate on 
>the
>specific command button, you can pass it the Active Control:
>
>ie, set the property to
>=fnProcedure(Screen.ActiveControl)
>
>You can parse the control name from the object passed and respond
>appropriately.
>
>Or presumably you can hook up controls 'WithEvents'.
>
>I haven't been following this thread, but it seems to me you could put a
>button on a continous form and operate on the current record textbox or
>index value.  Add a subRecord for each category?
>
>Ciao
>Jürgen Welz
>Edmonton, Alberta
>jwelz at hotmail.com
>
>
>
>
>
> >From: "Charlotte Foust" <cfoust at infostatsystems.com>
> >
> >Mark,
> >
> >You can create buttons programmatically, but binding code to them
> >requires directly manipulating the form's code module, which is a pain.
> >No control arrays in Access, unfortunately.  You can create the buttons
> >ahead of time and show or hide them and populate their captions based
> >on a table, though.  Why not use a table driven approach a la the
> >switchboard manager.
> >
> >Charlotte
> >
> >
> >-----Original Message-----
> >From: accessd-bounces at databaseadvisors.com
> >[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Mark A Matte
> >Sent: Thursday, February 23, 2006 9:52 AM
> >To: accessd at databaseadvisors.com
> >Subject: Re: [AccessD] Create/Hide Buttons on Form?
> >
> >
> >Jim,
> >
> >Yes...I have thought of that...but not as worried yet because I still
> >didn't know if I could, or how to create the buttons programatically.
> >Drop downs
> >are out of the question...but maybe I should move to VB.
> >
> >Thanks,
> >
> >Mark A. Matte
> >
> >
> >
> >
> > >From: "Jim DeMarco" <Jdemarco at hudsonhealthplan.org>
> > >Reply-To: Access Developers discussion and problem
> > >solving<accessd at databaseadvisors.com>
> > >To: "Access Developers discussion and problem solving"
> > ><accessd at databaseadvisors.com>
> > >Subject: Re: [AccessD] Create/Hide Buttons on Form?
> > >Date: Thu, 23 Feb 2006 09:44:07 -0500
> > >
> > >Mark,
> > >
> > >Have you thought about what happens when they've created enough new
> > >items to exceed your screen space?  Is a drop-down list out of the
> > >question
> >for
> > >this app?  If this were a VB app you'd have a much easier time
> > >creating
> >
> > >visual elements dynamically than with Access.
> > >
> > >Just some thoughts.
> > >
> > >Jim DeMarco
> > >
> > >-----Original Message-----
> > >From: accessd-bounces at databaseadvisors.com
> > >[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Mark A
> > >Matte
> > >Sent: Wednesday, February 22, 2006 12:12 PM
> > >To: accessd at databaseadvisors.com
> > >Subject: [AccessD] Create/Hide Buttons on Form?
> > >
> > >
> > >Hello All,
> > >
> > >I'm attempting an app related to restaurant/bar management in A2K.
> > >The
> >
> > >dilemma I have is in design.  I want them to have the ability to add
> > >new products/seats...but I'm not sure the best way to approach this.
> > >For instance...if they add a new menu item...I want a new button to
> > >appear. Should I make a predetermined number of buttons and hide them
> > >or should I program the app to create and place a new button when the
> > >new value is added ( if this, suggestions?)
> > >
> > >Thanks,
> > >
> > >Mark A. Matte





More information about the AccessD mailing list