[AccessD] Textbox special highlighting

jwcolby jwcolby at colbyconsulting.com
Tue Jan 3 11:12:14 CST 2012


Yep, just another option.  Many folks don't know about the MyCtl.controls(0) thing.

John W. Colby
Colby Consulting

Reality is what refuses to go away
when you do not believe in it

On 1/3/2012 11:33 AM, Jim Dettman wrote:
>
>   I did that for a while based on some code I picked up from Allen Brown's
> site, but most users didn't like it.  I was adjusting the label on the fly
> to indicate required vs non-required fields.
>
>   In the end, I ended up with simply high lighting all the required controls
> with a background change rather then setting/clearing when they switch from
> inquiry to edit mode.
>
> Jim.
>
> Private Function MarkAttachedLabel(ctl As Access.Control)
>
>        'Author:        Allen Browne    allen at allenbrowne.com
>        'Version:       21 September 2008.
>        'Copyright:     None. You can use this in your database for any
> purpose.
>        '               We request that you acknowledge the source in your
> code.
>        'Documentation: http://allenbrowne.com
>
> 10    On Error GoTo Err_Handler
>            'Purpose:   Bypass the error if a control has no attached label.
>
> 20        With ctl.Controls(0)
> 30            If Not .Caption Like "*[*]" Then
> 40                .Caption = .Caption&  "*"
> 50                .FontBold = True
> 60            End If
> 70        End With
>
> Exit_Handler:
> 80        Exit Function
>
> Err_Handler:
> 90        Resume Exit_Handler
> End Function
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby
> Sent: Tuesday, January 03, 2012 10:26 AM
> To: Access Developers discussion and problem solving
> Subject: Re: [AccessD] Textbox special highlighting
>
> Doug,
>
> It turns out that text boxes can have a label associated with it.  Every
> control has a controls
> collection and *if "connected"* the label is controls(0).  Thus
> txtMyCtl.Controls(0) will let you
> manipulate the label for the text box.  You can then play with the label
> background color, font etc
> as you think might be useful.  I do precisely this in my framework, as I set
> up a text box for a
> double click event I change the label color to a different color of blue.
>
> Of course I have a class for this.  ;)
>
> John W. Colby
> Colby Consulting
>
> Reality is what refuses to go away
> when you do not believe in it



More information about the AccessD mailing list