[AccessD] Create and place buttons with code

Jim Dettman jimdettman at verizon.net
Wed May 15 10:25:06 CDT 2019


Arthur,

<< how does one specify the top-left corner of a control?>>
  
That is given in TWIP's.  A TWIP is 1/1440 inch.

<< And relative to the window of interest?>>

Top and left is measured off the top and left corner of the form.

<< And how to specify that I want the buttons on the form footer, not the
body?>>

Here's the docs on the CreateControl method:

https://docs.microsoft.com/en-us/office/vba/api/access.application.createcon
trol

 You'd specify the section argument.   Here's a link the the constants for
that:

https://docs.microsoft.com/en-us/office/vba/api/access.acsection

 Keep in mind though that while you can create a form from scratch, adding
any code will cause the VBA project to become un-compiled.   If you can call
procedures in a standard module, then that is not an issue either.

 But usually its best to hide/un-hide controls and move them around as
needed just to avoid the issues.

Jim.

-----Original Message-----
From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
Arthur Fuller
Sent: Wednesday, May 15, 2019 9:52 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Create and place buttons with code

Thanks, Jim! You are invaluable. Just one question: how does one specify
the top-left corner of a control? By pixels? And relative to the window of
interest? And how to specify that I want the buttons on the form footer,
not the body? (I guess that was more than one question.)


On Wed, May 15, 2019 at 6:58 AM Jim Dettman via AccessD <
accessd at databaseadvisors.com> wrote:

>
>   You can move the buttons around all the time at run-time without issue
> (jut change their top and left properties).
>
>   And BTW, if you're creating the form each time from scratch, then you
> need
> not worry about the lifetime control limit.   And it's
> Application.CreateControl to add a control to a form.
>
> Jim.
>
>
>
> -----Original Message-----
> From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
> Arthur Fuller
> Sent: Tuesday, May 14, 2019 3:16 PM
> To: Access Developers discussion and problem solving
> Subject: Re: [AccessD] Create and place buttons with code
>
> Thanks, Jim. I shall try that approach instead. But your suggestion does
> not help me place the buttons. I shall work on that as a sub-project.
>
> On Tue, May 14, 2019 at 1:49 PM Daniel Waters <df.waters at outlook.com>
> wrote:
>
> > If anyone does hit that limit - the Access DeCorrupter will fix that for
> > you.
> >
> > Let me know if you want a copy.
> >
> > Dan
> >
> > -----Original Message-----
> > From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
> > Jim Dettman via AccessD
> > Sent: May 14, 2019 12:43
> > To: 'Access Developers discussion and problem solving'
> > Cc: Jim Dettman
> > Subject: Re: [AccessD] Create and place buttons with code
> >
> > Arthur,
> >
> >  Not a great idea.  Two reasons:
> >
> > 1. The lifetime limit for adding controls to a form (once you hit it,
you
> > can't add anymore).
> > 2. Adding code will leave the app un-compiled.
> >
> >  Better to place all the buttons you need and then hide/un-hide as
> needed.
> >
> > Jim.
> >
> > -----Original Message-----
> > From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
> > Arthur Fuller
> > Sent: Tuesday, May 14, 2019 10:58 AM
> > To: Access Developers discussion and problem solving
> > Subject: [AccessD] Create and place buttons with code
> >
> > Preamble: I'm trying to write a replacement for MsgBox, which basically
> > does everything MsgBox does, and then some.
> >
> > --
> > Arthur
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
>
>
> --
> Arthur
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>


-- 
Arthur
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list