Solved

Access 2003 Detatch/Attach a Label to a TextBox Programatically

Posted on 2008-06-25
11
945 Views
Last Modified: 2013-11-28
Anybody know how to do it?  To attach via the keyboard, click on the label, Ctl+X, click on the textbox, Ctl+C.  Same thing in reverse to detatch, but you have to move the label as it re-appears following the Ctl+C.  
0
Comment
Question by:GRayL
  • 6
  • 4
11 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
ID: 21868068
Hi Ray

Nope.  I immediately kill all labels associated with whatever other control I just created, and then create a separate label.
That way, I can align/resize the labels and controls independant of each other.
0
 
LVL 44

Author Comment

by:GRayL
ID: 21868937
I found this out.  You can refer to a label named lblAny attached to a textbox named tbxAny all on a form named frmAny using:

Forms!frmAny!tbxAny.Controls("lblAny")

When a control does not have an associated label, Forms!frmAny!tbxAny.Controls.Count = 0

If you enter that line in a code window, Intellisense will give you a drop down with 21 elements, one of which is Properties which has 41 values when the label is attached to a control, 49 when it is by itself.  Nothing in either list seems to tie it to the control it may be bound to.

I found out how it remove a control from a form, but this disassociation is the part that has me perplexed - there has to be a way.
0
 
LVL 75
ID: 21869534
I swear there is an 'attached' (or similar name) property for either a text box or label ... but, I can't find it.

mx
0
 
LVL 75
ID: 21869603
gRay ... open the Object Browser, select Access in the dd list, then scroll down to TextBox.

On the right, you will see AddColon, AutoLabel ...etc.  These are what I was thinking about ...


For example ... in Help:

AutoLabel Property
See AlsoApplies ToExampleSpecificsThe AutoLabel property specifies whether labels are automatically created and attached to new controls. Read/write Boolean.

expression.AutoLabel
expression    Required. An expression that returns one of the objects in the Applies To list.

Setting

The AutoLabel property uses the following settings.

Setting Description
Yes A label is attached to new controls.
No A label isn't attached to new controls.

You can set these properties only by using a control's default control style or the DefaultControl method in Visual Basic.

Remarks

Changes to the default control style setting affect only controls created on the current form or report. To change the default control style for all new forms or reports that you create without using a Microsoft Access wizard, see Specify a new template for forms and reports.

0
 
LVL 75
ID: 21869613
more:

AddColon Property
See AlsoApplies ToExampleSpecificsThe AddColon property specifies whether a colon follows the text in labels for new controls.
Read/write Boolean.

expression.AddColon
expression    Required. An expression that returns one of the objects in the Applies To list.

Setting
The AddColon property uses the following settings.

Setting Description
Yes A colon follows the text in labels for new controls.
No A colon doesn't follow the text in labels for new controls.

You can set these properties only by using a control's default control style or the DefaultControl method in Visual Basic.

Remarks
Changes to the default control style setting affect only controls created on the current form or report. To change the default control style for all new forms or reports that you create without using a Microsoft Access wizard, see Specify a new template for forms and reports.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 75
ID: 21869622
Also LabelX and LabelY.

Type these in the Immediate window, double click to highlight ... and hit F1 >>> right to Help File info.

mx
0
 
LVL 44

Author Comment

by:GRayL
ID: 21919258
Thanks Jim, I was all over the map on this one and it looks like 'Nope' is the answer.
0
 
LVL 75
ID: 21919338
?

Disassociating every label seems like a waste.   Because, if you need to make a text box Not Visible for example  (Me.Text1.Visible = False), then you need to add an extra line of code for the related label also.  If they are attached, you do not.

mx
0
 
LVL 44

Author Comment

by:GRayL
ID: 21919778
While snooping around another Access forum I came across this;

application.CreateControl "frmAny",acLabel,acDetail,"tbxAny","",1440,1080,1000,300

This command creates a control with default name Labeln, on form 'frmAny', associated with parent 'tbxAny',unbound to any field (""), at these twip locations.  

A similar application.DeleteControl will remove the control.

Jim, I wan't my poinks back!
0
 
LVL 75
ID: 21920277
Well yeah, but you didn't say Create ... you said 'Detatch/Attach' ...

mx
0
 
LVL 44

Author Comment

by:GRayL
ID: 21920749
Right your are.  Can't even read my own question.  Still snooping.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now