Shade textboxes of form based on checkbox

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

    Shade textboxes of form based on checkbox

    I must combine the information from two forms/tabs on a main form.

    The idea is to insert two checkboxes on the main form.

    Then based on the checkbox checked would then automatically highlight
    those textboxes that need to be filled in by the end user.

    Any advice on how best to do this?

    Thanks!

    Zuf
  • banem2@gmail.com

    #2
    Re: Shade textboxes of form based on checkbox

    On Jun 23, 9:23 pm, zufie <john.marru...@ illinois.govwro te:
    I must combine the information from two forms/tabs on a main form.
    >
    The idea is to insert two checkboxes on the main form.
    >
    Then based on the checkbox checked would then automatically highlight
    those textboxes that need to be filled in by the end user.
    >
    Any advice on how best to do this?
    >
    Thanks!
    >
    Zuf
    Hello,

    Here is my idea - use Tag property of the text box field.

    Assuming you have (for sample purpose here) 2 check boxes and several
    text box fields, say 4. By clicking first check box it will add shadow
    to first 2 text boxes and remove shadow from second 2 text boxes. Open
    form in design view and select first 2 text boxes. In property Tag
    write "Shadow1", for second 2 text boxes write "Shadow2" (without
    quotes).

    For first check box use this code:

    Private Sub chkBox1_Click()
    Dim ctl As Control

    For Each ctl In Me.Controls
    If ctl.Tag = "Shadow1" And chkBox1 = True _
    And ctl.ControlType = 109 Then
    ctl.SpecialEffe ct = 4
    ElseIf ctl.Tag <"Shadow1" And ctl.ControlType _
    = acTextBox Then
    ctl.SpecialEffe ct = 1
    End If
    Next
    End Sub

    Create similar code for second check box. 109 means text box
    (acTextBox), 4 means "Shadowed", 1 means "Flat".

    Use this idea to complete your form.

    Regards,
    Branislav Mihaljev
    Microsoft Access MVP

    Comment

    • zufie

      #3
      Re: Shade textboxes of form based on checkbox

      Thanks Branislav,

      The way I used your code I have all the textboxes resulting in being
      shadowed when I click on checkbox 1 and resulting in being flat when
      clicking on checkbox 2.

      The textboxes that must be raised when either checkbox is checked are
      almost the same.

      How can I get some of the textboxes not to become shadowed?

      Thanks,

      Zuf
      ban...@gmail.co m wrote:
      On Jun 23, 9:23�pm, zufie <john.marru...@ illinois.govwro te:
      I must combine the information from two forms/tabs on a main form.

      The idea is to insert two checkboxes on the main form.

      Then based on the checkbox checked would then automatically highlight
      those textboxes that need to be filled in by the end user.

      Any advice on how best to do this?

      Thanks!

      Zuf
      >
      Hello,
      >
      Here is my idea - use Tag property of the text box field.
      >
      Assuming you have (for sample purpose here) 2 check boxes and several
      text box fields, say 4. By clicking first check box it will add shadow
      to first 2 text boxes and remove shadow from second 2 text boxes. Open
      form in design view and select first 2 text boxes. In property Tag
      write "Shadow1", for second 2 text boxes write "Shadow2" (without
      quotes).
      >
      For first check box use this code:
      >
      Private Sub chkBox1_Click()
      Dim ctl As Control
      >
      For Each ctl In Me.Controls
      If ctl.Tag = "Shadow1" And chkBox1 = True _
      And ctl.ControlType = 109 Then
      ctl.SpecialEffe ct = 4
      ElseIf ctl.Tag <"Shadow1" And ctl.ControlType _
      = acTextBox Then
      ctl.SpecialEffe ct = 1
      End If
      Next
      End Sub
      >
      Create similar code for second check box. 109 means text box
      (acTextBox), 4 means "Shadowed", 1 means "Flat".
      >
      Use this idea to complete your form.
      >
      Regards,
      Branislav Mihaljev
      Microsoft Access MVP

      Comment

      Working...