Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Access 2003 Detatch/Attach a Label to a TextBox Programatically

Posted on 2008-06-25
11
951 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

829 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