By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,089 Members | 1,199 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,089 IT Pros & Developers. It's quick & easy.

Aligning Labels: not the text but the label itself.

P: n/a
Here is my situation. I have multiple labels on a form but only
certain ones will become visible while using the form. Depending on
which check box(s) you pick, on another form, determines the labels
that appear. I have that much working as of now. What I need to know
is, how do I format the labels to align underneath one and other. So
when I check the first check box, the corresponding label appears and
when I check the third check box it's label appears directly
underneath the first label leaving no gap or space for the invisible
second label.

Any help would be greatly appreciated.
Thank you.

Jared
Nov 13 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
You need to set the Top and Left properties of the labels in your checkboxes
code.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"Jared" <jm*****@hotmail.com> wrote in message
news:96**************************@posting.google.c om...
Here is my situation. I have multiple labels on a form but only
certain ones will become visible while using the form. Depending on
which check box(s) you pick, on another form, determines the labels
that appear. I have that much working as of now. What I need to know
is, how do I format the labels to align underneath one and other. So
when I check the first check box, the corresponding label appears and
when I check the third check box it's label appears directly
underneath the first label leaving no gap or space for the invisible
second label.

Any help would be greatly appreciated.
Thank you.

Jared

Nov 13 '05 #2

P: n/a
Jared, other things you could do so you don't have to worry about
hiding/realigning etc. are:
1-You could align them exactly where you want them in design view. Just
place one on top of the other. If/when you want to work with the one that
is behind the other one, select the top label then select the Format/Send to
back. Now you can select and edit the label that was behind the first one.

2-Instead of using 2 labels you could use the same label and change the
caption property instead of visible property. So depending on the checkbox
selected you could say"
If mycheck = True Then
Me.Mylabel.Caption = "This"
Else
Me.Mylabel.Caption = "That"
End If

--
Reggie

----------
"PC Datasheet" <no****@nospam.spam> wrote in message
news:o_******************@newsread2.news.atl.earth link.net...
You need to set the Top and Left properties of the labels in your checkboxes code.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"Jared" <jm*****@hotmail.com> wrote in message
news:96**************************@posting.google.c om...
Here is my situation. I have multiple labels on a form but only
certain ones will become visible while using the form. Depending on
which check box(s) you pick, on another form, determines the labels
that appear. I have that much working as of now. What I need to know
is, how do I format the labels to align underneath one and other. So
when I check the first check box, the corresponding label appears and
when I check the third check box it's label appears directly
underneath the first label leaving no gap or space for the invisible
second label.

Any help would be greatly appreciated.
Thank you.

Jared


Nov 13 '05 #3

P: n/a
The problem with that is, I will have somewhere around 15 labels, and
depending on which box is checked, any combination of labels could be
visible. There are too many combinations to write code for that
solution to work. It was a good idea though and definitely would work
if I only had 2 labels.

It's also not a simple as to just set the top and left properties.
When you do that you have to enter in specific numbers for the
location. If I could enter "Justify" in the top and left alignment
properties I would be done by now. Unfortunately I can't or just don't
know how to. Is there a way I could write a code that would do this?

Thanks for the ideas.
Nov 13 '05 #4

P: n/a
I guess my only question is if it's possible to write code to set the labels
visible property, then why not just change the caption of the labels. That
way they will always be aligned because you will be using the same label..
Maybe I'm not understanding what exactly you are trying to accomplish.
Sorry I couldn't help!

--
Reggie

----------
"Jared" <jm*****@hotmail.com> wrote in message
news:96**************************@posting.google.c om...
The problem with that is, I will have somewhere around 15 labels, and
depending on which box is checked, any combination of labels could be
visible. There are too many combinations to write code for that
solution to work. It was a good idea though and definitely would work
if I only had 2 labels.

It's also not a simple as to just set the top and left properties.
When you do that you have to enter in specific numbers for the
location. If I could enter "Justify" in the top and left alignment
properties I would be done by now. Unfortunately I can't or just don't
know how to. Is there a way I could write a code that would do this?

Thanks for the ideas.

Nov 13 '05 #5

P: n/a
Figured it out. Here is my code. It's not my complete code but here is
an example of six labels being put in a line depending on which check
box is checked and also a label that appears if no check boxes are
check.
[Forms]![Testfrm] is the form that contains the check boxes. The
labels are on their own form.

The IsXX are my check box names and there corresponding labels are
named XXLabel.

The variable "Location" was is to set the location of the label,
having it move up and down throughout the form depending on which
check boxes were checked.

The variable "NullChecks" was is to keep track of the number of check
boxes that are not check and if the total equals the total number of
check boxes then a the only thing that will become visible is a label
say no check boxes were checked.
Private Sub Form_Open(Cancel As Integer)
Dim Location As Integer
Dim NullChecks As Integer
Location = 250
NullChecks = 0

If [Forms]![Testfrm].IsNP.Value = -1 Then
Forms![popupfrm].NPLABEL.Visible = True
NPLABEL.Left = 500
NPLABEL.Top = Location
Else: Location = Location - 500
NullChecks = NullChecks + 1

End If

If [Forms]![Testfrm].IsTS.Value = -1 Then
Forms![popupfrm].TSLABEL.Visible = True
Location = Location + 500
TSLABEL.Top = Location
TSLABEL.Left = 500
Else: NullChecks = NullChecks + 1

End If

If [Forms]![Testfrm].IsJG.Value = -1 Then
Forms![popupfrm].JGLABEL.Visible = True
Location = Location + 500
JGLABEL.Top = Location
JGLABEL.Left = 500
Else: NullChecks = NullChecks + 1
End If

If [Forms]![Testfrm].Check16.Value = -1 Then
Forms![popupfrm].Label16.Visible = True
Location = Location + 500
Label16.Top = Location
Label16.Left = 500
Else: NullChecks = NullChecks + 1
End If

If [Forms]![Testfrm].Check18.Value = -1 Then
Forms![popupfrm].Label18.Visible = True
Location = Location + 500
Label18.Top = Location
Label18.Left = 500
Else: NullChecks = NullChecks + 1
End If

If [Forms]![Testfrm].Check20.Value = -1 Then
Forms![popupfrm].Label20.Visible = True
Location = Location + 500
Label20.Top = Location
Label20.Left = 500
Else: NullChecks = NullChecks + 1
End If

If NullChecks = 6 Then
Forms![popupfrm].LabelC.Visible = True
LabelC.Top = 250
LabelC.Left = 500
Else: Forms![popupfrm].LabelC.Visible = False
End If

End Sub

Something that confused me was when i entered a value for the Location
variable, it had to be a large number to make the label move. I first
tried numbers from 1 to 10 thinking that the code would think i meant
inches, i was wrong. I don't know what the code is thinking. Turns out
i needed to use values of at least 50 to see the label move, even then
it didn't move much. I ended up going with 250 and 500.

Anyway, I just thought I would post this in case anyone else was
interested or had the same scenario .
Nov 13 '05 #6

P: n/a
The small movement is because the values are expressed in twips(I believe).
Twip:
=====
A screen-independent unit used to ensure that placement and proportion of
screen elements in your screen application are the same on all display
systems. A twip is a unit of screen measurement equal to 1/20 of a
printer's point. There are approximately 1440 twips to a logical inch or
567 twips to a logical centimeter (the length of a screen item measuring one
inch or one centimeter when printed).
--
Reggie

----------
"Jared" <jm*****@hotmail.com> wrote in message
news:96**************************@posting.google.c om...
Figured it out. Here is my code. It's not my complete code but here is
an example of six labels being put in a line depending on which check
box is checked and also a label that appears if no check boxes are
check.
[Forms]![Testfrm] is the form that contains the check boxes. The
labels are on their own form.

The IsXX are my check box names and there corresponding labels are
named XXLabel.

The variable "Location" was is to set the location of the label,
having it move up and down throughout the form depending on which
check boxes were checked.

The variable "NullChecks" was is to keep track of the number of check
boxes that are not check and if the total equals the total number of
check boxes then a the only thing that will become visible is a label
say no check boxes were checked.
Private Sub Form_Open(Cancel As Integer)
Dim Location As Integer
Dim NullChecks As Integer
Location = 250
NullChecks = 0

If [Forms]![Testfrm].IsNP.Value = -1 Then
Forms![popupfrm].NPLABEL.Visible = True
NPLABEL.Left = 500
NPLABEL.Top = Location
Else: Location = Location - 500
NullChecks = NullChecks + 1

End If

If [Forms]![Testfrm].IsTS.Value = -1 Then
Forms![popupfrm].TSLABEL.Visible = True
Location = Location + 500
TSLABEL.Top = Location
TSLABEL.Left = 500
Else: NullChecks = NullChecks + 1

End If

If [Forms]![Testfrm].IsJG.Value = -1 Then
Forms![popupfrm].JGLABEL.Visible = True
Location = Location + 500
JGLABEL.Top = Location
JGLABEL.Left = 500
Else: NullChecks = NullChecks + 1
End If

If [Forms]![Testfrm].Check16.Value = -1 Then
Forms![popupfrm].Label16.Visible = True
Location = Location + 500
Label16.Top = Location
Label16.Left = 500
Else: NullChecks = NullChecks + 1
End If

If [Forms]![Testfrm].Check18.Value = -1 Then
Forms![popupfrm].Label18.Visible = True
Location = Location + 500
Label18.Top = Location
Label18.Left = 500
Else: NullChecks = NullChecks + 1
End If

If [Forms]![Testfrm].Check20.Value = -1 Then
Forms![popupfrm].Label20.Visible = True
Location = Location + 500
Label20.Top = Location
Label20.Left = 500
Else: NullChecks = NullChecks + 1
End If

If NullChecks = 6 Then
Forms![popupfrm].LabelC.Visible = True
LabelC.Top = 250
LabelC.Left = 500
Else: Forms![popupfrm].LabelC.Visible = False
End If

End Sub

Something that confused me was when i entered a value for the Location
variable, it had to be a large number to make the label move. I first
tried numbers from 1 to 10 thinking that the code would think i meant
inches, i was wrong. I don't know what the code is thinking. Turns out
i needed to use values of at least 50 to see the label move, even then
it didn't move much. I ended up going with 250 and 500.

Anyway, I just thought I would post this in case anyone else was
interested or had the same scenario .

Nov 13 '05 #7

P: n/a
"Reggie" <No**********@NoSpamsmittysinet.com> wrote in message news:<ur********************@comcast.com>...
The small movement is because the values are expressed in twips(I believe).
Twip:
=====
A screen-independent unit used to ensure that placement and proportion of
screen elements in your screen application are the same on all display
systems. A twip is a unit of screen measurement equal to 1/20 of a
printer's point. There are approximately 1440 twips to a logical inch or
567 twips to a logical centimeter (the length of a screen item measuring one
inch or one centimeter when printed).
--
Reggie


Reggie is correct about the units that are used for placement. You
don't have to deal with twips directly if you do something like:

MyControl.Top = MyControl.Top + intHowManyDown * MyControl.Height

James A. Fortune
Nov 13 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.