Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

repeating code multiple ck box

Discussion in 'Information Technology' started by lmv, Jul 28, 2006.

  1. lmv

    lmv
    Expand Collapse
    Guest

    I have a number of ck boxes on a form I want to do the following to...

    Private Sub Form_Current()

    If Me.CompleteCO = True Then
    Me.ColorTarget.Visible = False
    End If
    If Me.CompleteCO = False Then
    Me.ColorTarget.Visible = True
    End If
    End Sub

    Is there a concise way to accomplish this?
    Thanks!
    (check box names)
    CompleteDB
    CompleteP
    CompleteDS
    CompleteB
    CompleteS
    (Text Box I want to change visiblity on)
    DBTarget
    PTarget
    DSTarget
    BTarget
    STarget
     
  2. Loading...

    Similar Threads Forum Date
    USA History Repeating Itself: U.S. Hawks Hover Over Iran Breaking News Oct 19, 2011
    Introducing The Spn Code Of Forum Etiquette Announcements Feb 20, 2016
    UK Sikh 'code of silence' on sexual grooming Breaking News Sep 2, 2013
    Can a Dress Code Bar Ethnic and Religious Attire Based on Customer Preferences in the US? Questions and Answers May 3, 2011
    Pacific Code Exempts Religious Drivers (Fiji) Breaking News Feb 16, 2011

  3. John Vinson

    John Vinson
    Expand Collapse
    Guest

    On Sun, 25 Jun 2006 18:04:01 -0700, lmv
    <lmv@discussions.microsoft.com> wrote:

    >I have a number of ck boxes on a form I want to do the following to...
    >
    >Private Sub Form_Current()
    >
    >If Me.CompleteCO = True Then
    > Me.ColorTarget.Visible = False
    > End If
    > If Me.CompleteCO = False Then
    > Me.ColorTarget.Visible = True
    > End If
    > End Sub
    >
    >Is there a concise way to accomplish this?
    >Thanks!
    >(check box names)
    >CompleteDB
    >CompleteP
    >CompleteDS
    >CompleteB
    >CompleteS
    >(Text Box I want to change visiblity on)
    >DBTarget
    >PTarget
    >DSTarget
    >BTarget
    >STarget
    >


    One way would be to create an array, or even a small table, with two
    columns, one for the checkbox and one for the corresponding textbox. I
    would suggest using a table especially if the list of controls might
    be changing in the future, as it's easier to maintain. You'ld then use
    code like

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Set db = CurrentDb
    Set rs = db.OpenRecordset("tblVisibleToggle")
    rs.MoveFirst
    Do Until rs.EOF
    Me!Controls(rs!Textboxname).Visible = Not rs.Checkboxname
    rs.MoveNext
    Loop


    John W. Vinson[MVP]
     
  4. lmv

    lmv
    Expand Collapse
    Guest

    I'm sorry I don't know what you mean. This is a small form that is based on
    a small table of ck boxes for events. The target field is not on the table it
    is unbound with a calculated date field. I want the date field to disappear
    when the box is checked. and it works with the first line. I just don't know
    how to add the additional lines. And I have four other tables that are the
    same principle and so I thought maybe there was some other way to do the job.
    Would you tell me how to combine the additional fields. Thank You!


    Private Sub Form_Current()

    If Me.CompleteCO = True Then
    'Me.CompleteDB = True Then
    'Me.CompleteP = True Then
    'Me.CompleteDS = True Then
    'Me.CompleteB = True Then
    'Me.CompleteS = True Then

    Me.ColorTarget.Visible = False
    'Me.DBTarget.Visible = False
    'Me.PTarget.Visible = False
    'Me.DSTarget.Visible = False
    'Me.BTarget.Visible = False
    'Me.STarget.Visible = False
    End If
    If Me.CompleteCO = False Then
    Me.ColorTarget.Visible = True

    End If
    End Sub

    "John Vinson" wrote:

    > On Sun, 25 Jun 2006 18:04:01 -0700, lmv
    > <lmv@discussions.microsoft.com> wrote:
    >
    > >I have a number of ck boxes on a form I want to do the following to...
    > >
    > >Private Sub Form_Current()
    > >
    > >If Me.CompleteCO = True Then
    > > Me.ColorTarget.Visible = False
    > > End If
    > > If Me.CompleteCO = False Then
    > > Me.ColorTarget.Visible = True
    > > End If
    > > End Sub
    > >
    > >Is there a concise way to accomplish this?
    > >Thanks!
    > >(check box names)
    > >CompleteDB
    > >CompleteP
    > >CompleteDS
    > >CompleteB
    > >CompleteS
    > >(Text Box I want to change visiblity on)
    > >DBTarget
    > >PTarget
    > >DSTarget
    > >BTarget
    > >STarget
    > >

    >
    > One way would be to create an array, or even a small table, with two
    > columns, one for the checkbox and one for the corresponding textbox. I
    > would suggest using a table especially if the list of controls might
    > be changing in the future, as it's easier to maintain. You'ld then use
    > code like
    >
    > Dim db As DAO.Database
    > Dim rs As DAO.Recordset
    > Set db = CurrentDb
    > Set rs = db.OpenRecordset("tblVisibleToggle")
    > rs.MoveFirst
    > Do Until rs.EOF
    > Me!Controls(rs!Textboxname).Visible = Not rs.Checkboxname
    > rs.MoveNext
    > Loop
    >
    >
    > John W. Vinson[MVP]
    >
     

Share This Page