Aligning Labels: not the text but the label itself.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jared

    #1

    Aligning Labels: not the text but the label itself.

    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
  • PC Datasheet

    #2
    Re: Aligning Labels: not the text but the label itself.

    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
    resource@pcdata sheet.com



    "Jared" <jmgriep@hotmai l.com> wrote in message
    news:9646e57d.0 407281048.39536 fe9@posting.goo gle.com...[color=blue]
    > 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[/color]


    Comment

    • Reggie

      #3
      Re: Aligning Labels: not the text but the label itself.

      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.Capt ion = "This"
      Else
      Me.Mylabel.Capt ion = "That"
      End If

      --
      Reggie

      ----------
      "PC Datasheet" <nospam@nospam. spam> wrote in message
      news:o_SNc.1709 4$iK.15462@news read2.news.atl. earthlink.net.. .[color=blue]
      > You need to set the Top and Left properties of the labels in your[/color]
      checkboxes[color=blue]
      > code.
      >
      > --
      > PC Datasheet
      > Your Resource For Help With Access, Excel And Word Applications
      > resource@pcdata sheet.com
      > www.pcdatasheet.com
      >
      >
      > "Jared" <jmgriep@hotmai l.com> wrote in message
      > news:9646e57d.0 407281048.39536 fe9@posting.goo gle.com...[color=green]
      > > 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[/color]
      >
      >[/color]


      Comment

      • Jared

        #4
        Re: Aligning Labels: not the text but the label itself.

        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.

        Comment

        • Reggie

          #5
          Re: Aligning Labels: not the text but the label itself.

          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" <jmgriep@hotmai l.com> wrote in message
          news:9646e57d.0 407290547.3a8ee dae@posting.goo gle.com...[color=blue]
          > 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.[/color]


          Comment

          • Jared

            #6
            Re: Aligning Labels: not the text but the label itself.

            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(Cance l As Integer)
            Dim Location As Integer
            Dim NullChecks As Integer
            Location = 250
            NullChecks = 0

            If [Forms]![Testfrm].IsNP.Value = -1 Then
            Forms![popupfrm].NPLABEL.Visibl e = 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.Visibl e = 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.Visibl e = 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.Visibl e = 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.Visibl e = 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.Visibl e = 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 .

            Comment

            • Reggie

              #7
              Re: Aligning Labels: not the text but the label itself.

              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" <jmgriep@hotmai l.com> wrote in message
              news:9646e57d.0 407300538.6c395 9c3@posting.goo gle.com...[color=blue]
              > 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(Cance l As Integer)
              > Dim Location As Integer
              > Dim NullChecks As Integer
              > Location = 250
              > NullChecks = 0
              >
              > If [Forms]![Testfrm].IsNP.Value = -1 Then
              > Forms![popupfrm].NPLABEL.Visibl e = 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.Visibl e = 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.Visibl e = 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.Visibl e = 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.Visibl e = 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.Visibl e = 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 .[/color]


              Comment

              • James Fortune

                #8
                Re: Aligning Labels: not the text but the label itself.

                "Reggie" <NoSpamreggie@N oSpamsmittysine t.com> wrote in message news:<ur2dnSvJt 9x6NJfcRVn-sw@comcast.com> ...[color=blue]
                > 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[/color]

                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.Heigh t

                James A. Fortune

                Comment

                Working...