Welcome to SPN

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

Sign Up Now!

MULTIPLE checkboxes triggers visibility

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

  1. lmv

    lmv
    Expand Collapse
    Guest

    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.
    ---------code-------------
    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

    'repeat above

    End If
    End Sub
    -------------------------------------------
    Also, if I wanted to make the whole record invisible after completion and I
    had a ckbox "finished" what would be the code to surpress it?

    Thank you!
     
  2. Loading...


  3. schasteen

    schasteen
    Expand Collapse
    Guest

    If Me.CompleteCO = True Then
    Me.ColorTarget.Visible = False
    else
    Me.ColorTarget.Visible = true
    End if

    If Me.CompleteDB = True Then
    Me.DBTarget.Visible = False
    else
    Me.DBTarget.Visible = true
    End if

    You need an if then else for each. You could also try:
    Me![ColorTarget].Visible = Not Me![CompleteCO]
    Me![DBTarget].Visible = Not Me![CompleteDB]
    Me![PTarget].Visible = Not Me![CompleteP]

    "lmv" wrote:

    > 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.
    > ---------code-------------
    > 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
    >
    > 'repeat above
    >
    > End If
    > End Sub
    > -------------------------------------------
    > Also, if I wanted to make the whole record invisible after completion and I
    > had a ckbox "finished" what would be the code to surpress it?
    >
    > Thank you!
    >
     
  4. lmv

    lmv
    Expand Collapse
    Guest

    Thank you for the response I tried (with the proper corresponding control on
    the clk event) but it doesn't work: I get an error on Current... I don't know
    what to put before the other suggestion you made so I couldn't try it. I am
    not familiar enough with "writing" code to know if it matters if there are
    spaces/tab spaces before the code in different places etc. Any additional
    direction would be greatly appreciated.
    Thanks!!

    Private Sub Form_Current()
    If Me.CompleteCO = True Then
    Me.ColorTarget.Visible = False
    Else
    Me.ColorTarget.Visible = True
    End If

    If Me.CompleteDB = True Then
    Me.DBTarget.Visible = False
    Else
    Me.DBTarget.Visible = True
    End If

    If Me.CompleteB = True Then
    Me.BTarget.Visible = False
    Else
    Me.BTarget.Visible = True
    End If

    If Me.CompleteS = True Then
    Me.STarget.Visible = False
    Else
    Me.STarget.Visible = True
    End If

    If Me.CompleteP = True Then
    Me.PTarget.Visible = False
    Else
    Me.CPTarget.Visible = True
    End If


    If Me.CompleteDS = True Then
    Me.DSTarget.Visible = False
    Else
    Me.DSTarget.Visible = True
    End If
    End Sub
     
  5. schasteen

    schasteen
    Expand Collapse
    Guest

    I am not sure what you are asking for. What is your error with the on
    current event? I also do not understand what you me mean with click event.
    I would put the corresponding if then statement in the after update event of
    the appropriate check box. With the other example you don't have to put
    anything in front of it. It sets the visible property to the opposite of the
    checkbox. It directly replaces the if then statements. Hope this helps, but
    if not please let me know the error you are getting.

    "lmv" wrote:

    > Thank you for the response I tried (with the proper corresponding control on
    > the clk event) but it doesn't work: I get an error on Current... I don't know
    > what to put before the other suggestion you made so I couldn't try it. I am
    > not familiar enough with "writing" code to know if it matters if there are
    > spaces/tab spaces before the code in different places etc. Any additional
    > direction would be greatly appreciated.
    > Thanks!!
    >
    > Private Sub Form_Current()
    > If Me.CompleteCO = True Then
    > Me.ColorTarget.Visible = False
    > Else
    > Me.ColorTarget.Visible = True
    > End If
    >
    > If Me.CompleteDB = True Then
    > Me.DBTarget.Visible = False
    > Else
    > Me.DBTarget.Visible = True
    > End If
    >
    > If Me.CompleteB = True Then
    > Me.BTarget.Visible = False
    > Else
    > Me.BTarget.Visible = True
    > End If
    >
    > If Me.CompleteS = True Then
    > Me.STarget.Visible = False
    > Else
    > Me.STarget.Visible = True
    > End If
    >
    > If Me.CompleteP = True Then
    > Me.PTarget.Visible = False
    > Else
    > Me.CPTarget.Visible = True
    > End If
    >
    >
    > If Me.CompleteDS = True Then
    > Me.DSTarget.Visible = False
    > Else
    > Me.DSTarget.Visible = True
    > End If
    > End Sub
     
  6. lmv

    lmv
    Expand Collapse
    Guest

    Thanks I got it now! I did use the 2nd way. Can you help with my 2nd question
    which was if I wanted to make the whole record invisible after completion and
    I
    had a ckbox "finished" what would be the code to surpress the whole record?

    Thanks again!!




    "schasteen" wrote:

    > I am not sure what you are asking for. What is your error with the on
    > current event? I also do not understand what you me mean with click event.
    > I would put the corresponding if then statement in the after update event of
    > the appropriate check box. With the other example you don't have to put
    > anything in front of it. It sets the visible property to the opposite of the
    > checkbox. It directly replaces the if then statements. Hope this helps, but
    > if not please let me know the error you are getting.
    >
    > "lmv" wrote:
    >
    > > Thank you for the response I tried (with the proper corresponding control on
    > > the clk event) but it doesn't work: I get an error on Current... I don't know
    > > what to put before the other suggestion you made so I couldn't try it. I am
    > > not familiar enough with "writing" code to know if it matters if there are
    > > spaces/tab spaces before the code in different places etc. Any additional
    > > direction would be greatly appreciated.
    > > Thanks!!
    > >
    > > Private Sub Form_Current()
    > > If Me.CompleteCO = True Then
    > > Me.ColorTarget.Visible = False
    > > Else
    > > Me.ColorTarget.Visible = True
    > > End If
    > >
    > > If Me.CompleteDB = True Then
    > > Me.DBTarget.Visible = False
    > > Else
    > > Me.DBTarget.Visible = True
    > > End If
    > >
    > > If Me.CompleteB = True Then
    > > Me.BTarget.Visible = False
    > > Else
    > > Me.BTarget.Visible = True
    > > End If
    > >
    > > If Me.CompleteS = True Then
    > > Me.STarget.Visible = False
    > > Else
    > > Me.STarget.Visible = True
    > > End If
    > >
    > > If Me.CompleteP = True Then
    > > Me.PTarget.Visible = False
    > > Else
    > > Me.CPTarget.Visible = True
    > > End If
    > >
    > >
    > > If Me.CompleteDS = True Then
    > > Me.DSTarget.Visible = False
    > > Else
    > > Me.DSTarget.Visible = True
    > > End If
    > > End Sub
     
  7. schasteen

    schasteen
    Expand Collapse
    Guest

    In the afterupdate event of finished

    Me![ColorTarget].Visible = not Me![Finished]
    Me![DBTarget].Visible = not Me![Finished]
    Me![BTarget].Visible = not Me![Finished]
    Me![STarget].Visible = not Me![Finished]
    Me![CPTarget].Visible = not Me![Finished]
    Me![DSTarget].Visible = not Me![Finished]

    Then in the on current event

    If Me![Finished] then
    Me![ColorTarget].Visible = not Me![Finished]
    Me![DBTarget].Visible = not Me![Finished]
    Me![BTarget].Visible = not Me![Finished]
    Me![STarget].Visible = not Me![Finished]
    Me![CPTarget].Visible = not Me![Finished]
    Me![DSTarget].Visible = not Me![Finished]
    else
    Existing code
    end if




    "lmv" wrote:

    > Thanks I got it now! I did use the 2nd way. Can you help with my 2nd question
    > which was if I wanted to make the whole record invisible after completion and
    > I
    > had a ckbox "finished" what would be the code to surpress the whole record?
    >
    > Thanks again!!
    >
    >
    >
    >
    > "schasteen" wrote:
    >
    > > I am not sure what you are asking for. What is your error with the on
    > > current event? I also do not understand what you me mean with click event.
    > > I would put the corresponding if then statement in the after update event of
    > > the appropriate check box. With the other example you don't have to put
    > > anything in front of it. It sets the visible property to the opposite of the
    > > checkbox. It directly replaces the if then statements. Hope this helps, but
    > > if not please let me know the error you are getting.
    > >
    > > "lmv" wrote:
    > >
    > > > Thank you for the response I tried (with the proper corresponding control on
    > > > the clk event) but it doesn't work: I get an error on Current... I don't know
    > > > what to put before the other suggestion you made so I couldn't try it. I am
    > > > not familiar enough with "writing" code to know if it matters if there are
    > > > spaces/tab spaces before the code in different places etc. Any additional
    > > > direction would be greatly appreciated.
    > > > Thanks!!
    > > >
    > > > Private Sub Form_Current()
    > > > If Me.CompleteCO = True Then
    > > > Me.ColorTarget.Visible = False
    > > > Else
    > > > Me.ColorTarget.Visible = True
    > > > End If
    > > >
    > > > If Me.CompleteDB = True Then
    > > > Me.DBTarget.Visible = False
    > > > Else
    > > > Me.DBTarget.Visible = True
    > > > End If
    > > >
    > > > If Me.CompleteB = True Then
    > > > Me.BTarget.Visible = False
    > > > Else
    > > > Me.BTarget.Visible = True
    > > > End If
    > > >
    > > > If Me.CompleteS = True Then
    > > > Me.STarget.Visible = False
    > > > Else
    > > > Me.STarget.Visible = True
    > > > End If
    > > >
    > > > If Me.CompleteP = True Then
    > > > Me.PTarget.Visible = False
    > > > Else
    > > > Me.CPTarget.Visible = True
    > > > End If
    > > >
    > > >
    > > > If Me.CompleteDS = True Then
    > > > Me.DSTarget.Visible = False
    > > > Else
    > > > Me.DSTarget.Visible = True
    > > > End If
    > > > End Sub
     
  8. lmv

    lmv
    Expand Collapse
    Guest

    Ok so it is basically the same... is there a simple answer to what the
    difference is between the OnClick event and the afterupdate for the ckbox?
    Thanks again for your help!

    "schasteen" wrote:

    > In the afterupdate event of finished
    >
    > Me![ColorTarget].Visible = not Me![Finished]
    > Me![DBTarget].Visible = not Me![Finished]
    > Me![BTarget].Visible = not Me![Finished]
    > Me![STarget].Visible = not Me![Finished]
    > Me![CPTarget].Visible = not Me![Finished]
    > Me![DSTarget].Visible = not Me![Finished]
    >
    > Then in the on current event
    >
    > If Me![Finished] then
    > Me![ColorTarget].Visible = not Me![Finished]
    > Me![DBTarget].Visible = not Me![Finished]
    > Me![BTarget].Visible = not Me![Finished]
    > Me![STarget].Visible = not Me![Finished]
    > Me![CPTarget].Visible = not Me![Finished]
    > Me![DSTarget].Visible = not Me![Finished]
    > else
    > Existing code
    > end if
    >
    >
    >
    >
    > "lmv" wrote:
    >
    > > Thanks I got it now! I did use the 2nd way. Can you help with my 2nd question
    > > which was if I wanted to make the whole record invisible after completion and
    > > I
    > > had a ckbox "finished" what would be the code to surpress the whole record?
    > >
    > > Thanks again!!
    > >
    > >
    > >
    > >
    > > "schasteen" wrote:
    > >
    > > > I am not sure what you are asking for. What is your error with the on
    > > > current event? I also do not understand what you me mean with click event.
    > > > I would put the corresponding if then statement in the after update event of
    > > > the appropriate check box. With the other example you don't have to put
    > > > anything in front of it. It sets the visible property to the opposite of the
    > > > checkbox. It directly replaces the if then statements. Hope this helps, but
    > > > if not please let me know the error you are getting.
    > > >
    > > > "lmv" wrote:
    > > >
    > > > > Thank you for the response I tried (with the proper corresponding control on
    > > > > the clk event) but it doesn't work: I get an error on Current... I don't know
    > > > > what to put before the other suggestion you made so I couldn't try it. I am
    > > > > not familiar enough with "writing" code to know if it matters if there are
    > > > > spaces/tab spaces before the code in different places etc. Any additional
    > > > > direction would be greatly appreciated.
    > > > > Thanks!!
    > > > >
    > > > > Private Sub Form_Current()
    > > > > If Me.CompleteCO = True Then
    > > > > Me.ColorTarget.Visible = False
    > > > > Else
    > > > > Me.ColorTarget.Visible = True
    > > > > End If
    > > > >
    > > > > If Me.CompleteDB = True Then
    > > > > Me.DBTarget.Visible = False
    > > > > Else
    > > > > Me.DBTarget.Visible = True
    > > > > End If
    > > > >
    > > > > If Me.CompleteB = True Then
    > > > > Me.BTarget.Visible = False
    > > > > Else
    > > > > Me.BTarget.Visible = True
    > > > > End If
    > > > >
    > > > > If Me.CompleteS = True Then
    > > > > Me.STarget.Visible = False
    > > > > Else
    > > > > Me.STarget.Visible = True
    > > > > End If
    > > > >
    > > > > If Me.CompleteP = True Then
    > > > > Me.PTarget.Visible = False
    > > > > Else
    > > > > Me.CPTarget.Visible = True
    > > > > End If
    > > > >
    > > > >
    > > > > If Me.CompleteDS = True Then
    > > > > Me.DSTarget.Visible = False
    > > > > Else
    > > > > Me.DSTarget.Visible = True
    > > > > End If
    > > > > End Sub
     
  9. schasteen

    schasteen
    Expand Collapse
    Guest

    My memory is very bad, but if I remeber correctly the click event occurs
    before the value has changed. The after update event ensures that the value
    is there. Maybe sombody else can give you a better answer.

    "lmv" wrote:

    > Ok so it is basically the same... is there a simple answer to what the
    > difference is between the OnClick event and the afterupdate for the ckbox?
    > Thanks again for your help!
    >
    > "schasteen" wrote:
    >
    > > In the afterupdate event of finished
    > >
    > > Me![ColorTarget].Visible = not Me![Finished]
    > > Me![DBTarget].Visible = not Me![Finished]
    > > Me![BTarget].Visible = not Me![Finished]
    > > Me![STarget].Visible = not Me![Finished]
    > > Me![CPTarget].Visible = not Me![Finished]
    > > Me![DSTarget].Visible = not Me![Finished]
    > >
    > > Then in the on current event
    > >
    > > If Me![Finished] then
    > > Me![ColorTarget].Visible = not Me![Finished]
    > > Me![DBTarget].Visible = not Me![Finished]
    > > Me![BTarget].Visible = not Me![Finished]
    > > Me![STarget].Visible = not Me![Finished]
    > > Me![CPTarget].Visible = not Me![Finished]
    > > Me![DSTarget].Visible = not Me![Finished]
    > > else
    > > Existing code
    > > end if
    > >
    > >
    > >
    > >
    > > "lmv" wrote:
    > >
    > > > Thanks I got it now! I did use the 2nd way. Can you help with my 2nd question
    > > > which was if I wanted to make the whole record invisible after completion and
    > > > I
    > > > had a ckbox "finished" what would be the code to surpress the whole record?
    > > >
    > > > Thanks again!!
    > > >
    > > >
    > > >
    > > >
    > > > "schasteen" wrote:
    > > >
    > > > > I am not sure what you are asking for. What is your error with the on
    > > > > current event? I also do not understand what you me mean with click event.
    > > > > I would put the corresponding if then statement in the after update event of
    > > > > the appropriate check box. With the other example you don't have to put
    > > > > anything in front of it. It sets the visible property to the opposite of the
    > > > > checkbox. It directly replaces the if then statements. Hope this helps, but
    > > > > if not please let me know the error you are getting.
    > > > >
    > > > > "lmv" wrote:
    > > > >
    > > > > > Thank you for the response I tried (with the proper corresponding control on
    > > > > > the clk event) but it doesn't work: I get an error on Current... I don't know
    > > > > > what to put before the other suggestion you made so I couldn't try it. I am
    > > > > > not familiar enough with "writing" code to know if it matters if there are
    > > > > > spaces/tab spaces before the code in different places etc. Any additional
    > > > > > direction would be greatly appreciated.
    > > > > > Thanks!!
    > > > > >
    > > > > > Private Sub Form_Current()
    > > > > > If Me.CompleteCO = True Then
    > > > > > Me.ColorTarget.Visible = False
    > > > > > Else
    > > > > > Me.ColorTarget.Visible = True
    > > > > > End If
    > > > > >
    > > > > > If Me.CompleteDB = True Then
    > > > > > Me.DBTarget.Visible = False
    > > > > > Else
    > > > > > Me.DBTarget.Visible = True
    > > > > > End If
    > > > > >
    > > > > > If Me.CompleteB = True Then
    > > > > > Me.BTarget.Visible = False
    > > > > > Else
    > > > > > Me.BTarget.Visible = True
    > > > > > End If
    > > > > >
    > > > > > If Me.CompleteS = True Then
    > > > > > Me.STarget.Visible = False
    > > > > > Else
    > > > > > Me.STarget.Visible = True
    > > > > > End If
    > > > > >
    > > > > > If Me.CompleteP = True Then
    > > > > > Me.PTarget.Visible = False
    > > > > > Else
    > > > > > Me.CPTarget.Visible = True
    > > > > > End If
    > > > > >
    > > > > >
    > > > > > If Me.CompleteDS = True Then
    > > > > > Me.DSTarget.Visible = False
    > > > > > Else
    > > > > > Me.DSTarget.Visible = True
    > > > > > End If
    > > > > > End Sub
     
  10. lmv

    lmv
    Expand Collapse
    Guest

    I am having a bit of a problem now... there are 4 subforms that have these
    ckboxes. The first one worked fine... now when I have used the code on the
    2nd subform I am getting error 13 datatype mismatch on since this is being
    run in the Current event of each subform do I need an error handler or some
    other code to qualify each subform? Haven't even tried adding the other2
    yet... any ideas?
    Thanks

    -------------------------------------------------------
    Private Sub Form_Current()

    Me![ColorTarget].Visible = Not Me![CompleteCO]
    Me![DBTarget].Visible = Not Me![CompleteDB]
    Me![PTarget].Visible = Not Me![CompleteP]
    Me![DSTarget].Visible = Not Me![CompleteDS]
    Me![STarget].Visible = Not Me![CompleteS]
    Me![BTarget].Visible = Not Me![CompleteB]
    End Sub
    --------------------------
    "lmv" wrote:

    > 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.
    > ---------code-------------
    > 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
    >
    > 'repeat above
    >
    > End If
    > End Sub
    > -------------------------------------------
    > Also, if I wanted to make the whole record invisible after completion and I
    > had a ckbox "finished" what would be the code to surpress it?
    >
    > Thank you!
    >
     

Share This Page