Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Sep 2007
    Location
    Chatham, Kent, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Button Visible/Not Visible (97)

    My database main form has a check box on it. When the check box is checked, the command button next to it becomes visible using the following code on the mouse up event:

    If Check01.Value = True Then
    Command43.Visible = False
    ElseIf Check01.Value = False Then
    Command43.Visible = True
    End If

    This works a treat except that when I move to the next record the button remains visible even if the check box is unchecked since nobody told it to be not visible!

    My question is, where does the code need to be to carry out the check as above when a different record is selected?

    Regards

    Graeme

  2. #2
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Button Visible/Not Visible (97)

    Hi,

    you can use the code on the Main Form's 'On Current' event.
    and you can simplify the code to

    Command43.Visible = Check01.Value

    hope that helps?
    Thanks,

    pmatz

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Button Visible/Not Visible (97)

    I would make that

    Command43.Visible = Not Check01.Value

  4. #4
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Button Visible/Not Visible (97)

    <img src=/S/yep.gif border=0 alt=yep width=15 height=15>

    my mistake!
    Thanks,

    pmatz

  5. #5
    2 Star Lounger
    Join Date
    Sep 2007
    Location
    Chatham, Kent, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Button Visible/Not Visible (97)

    It all now works like a dream!!!

    Thank you very much

    Regards

    Graeme

  6. #6
    2 Star Lounger
    Join Date
    Sep 2007
    Location
    Chatham, Kent, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Button Visible/Not Visible (97)

    Hans/Matz

    I would like to ask a similar question if I may.

    The code you suggested worked fine on the main for of my database, however I tried to apply it to a form with the button which needed hiding on a sub form. In this instance it would only work after the form is moved to the adjacent record and back again.

    I've tried your code line in various events and I've messed about with the SetValue action all to no avail!

    I've attached an example database to show the problem. There are two tables, FrmMain is based on the first table TblMain and FrmSub is based on TblSub. FrmMain has a subform which has a boolean field from TblSub on it. When this check box is checked, the button is supposed to appear and vice versa.

    All offers of where to stick my code gratefully received!

    Regards

    Graeme
    Attached Files Attached Files

  7. #7
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Button Visible/Not Visible (97)

    Hey Graeme,

    you need to have the code in the AfterUpdate of the check box also,

    Private Sub Sub02_AfterUpdate()

    Command6.Visible = Sub02.Value
    RunCommand acCmdSaveRecord

    End Sub

    That keeps the buttons.visible property in line with whats going on in the check box. the Form.Current event keeps the button.visible in line when you cycle through records.... if that makes sense!

    [img]/forums/images/smilies/smile.gif[/img]
    Thanks,

    pmatz

  8. #8
    2 Star Lounger
    Join Date
    Sep 2007
    Location
    Chatham, Kent, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Button Visible/Not Visible (97)

    Brillient!

    Thanks

    Graeme

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •