Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Access 2003 Detatch/Attach a Label to a TextBox Programatically

Posted on 2008-06-25
11
Medium Priority
?
962 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
[X]
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
  • 6
  • 4
11 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 2000 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

604 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