Solved

Access 2003 Detatch/Attach a Label to a TextBox Programatically

Posted on 2008-06-25
11
952 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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
 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

679 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