Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hiding controls (2000)

    Hi,
    I have this coding on the On Load event of a form:

    <hr>If Forms![FrmMain]![Visible] = True Then
    Me.CmdBriefsRpt.Visible = False
    Me.CmdCaseTypeRpt.Visible = True
    Me.CmdRptOffenceCat.Visible = True
    Me.CmdTimeEstimate.Visible = True
    Me.CmdEmailRpts.Visible = True
    Me.CmdStats.Visible = True
    Me.CmdArchive.Visible = True
    Me.Detail.Visible = True
    Me.Box21.Visible = True
    Me.CmdRptExit.Visible = True
    End If
    Exit Sub
    If Forms![FrmMain]![Visible] = False Then
    Me.CmdBriefsRpt.Visible = True
    Me.CmdCaseTypeRpt.Visible = False
    Me.CmdRptOffenceCat.Visible = False
    Me.CmdTimeEstimate.Visible = False
    Me.CmdEmailRpts.Visible = False
    Me.CmdStats.Visible = False
    Me.CmdArchive.Visible = False
    Me.Detail.Visible = False
    Me.Box21.Visible = False
    Me.CmdRptExit.Visible = True
    End If<hr>

    As you can see, in FrmMain, there is a true/false value, (Visible) which when a control is clicked, sets this to either True or False and then opens the form that the coding is quoted for above.
    The problem is, its not hiding the Command Buttons that I would like. It just opens as normal................any ideas?

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

    Re: Hiding controls (2000)

    I would rename the control on the calling form. Using Visible as name for a control may cause confusion, since Visible is also a property of a form.

    For example, if it is a chack box, name it chkVisible, and change the code accordingly. By the way, the code can be simplified:

    Dim f As Boolean
    f = Forms!frmMain!chkVisible
    Me.CmdBriefsRpt.Visible = Not f
    Me.CmdCaseTypeRpt.Visible = f
    Me.CmdRptOffenceCat.Visible = f
    Me.CmdTimeEstimate.Visible = f
    Me.CmdEmailRpts.Visible = f
    Me.CmdStats.Visible = f
    Me.CmdArchive.Visible = f
    Me.Detail.Visible = f
    Me.Box21.Visible = f

    I removed the line for Me.CmdRptExit.Visible since it is set to True regardless of the value of the control on frmMain.

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Hiding controls (2000)

    Further to Hans comments, you have a line of code Exit Sub before this line
    If Forms![FrmMain]![Visible] = False Then

    This means the line above never executes, so your code does not set the viible property to false.

    The way to handle this type to situation is to have:

    If condition is true then
    statements to execute
    else
    alternative statements
    end if
    Regards
    John



  4. #4
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding controls (2000)

    This now displays nothing in the form.

    Below is a snippet of the code of one of the controls from the main form:

    <hr>Private Sub CmdBriefs_Click()
    Me.ChkVisible = 0
    On Error GoTo Err_CmdBriefs_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "FrmRptMenu"
    DoCmd.OpenForm stDocName, , , stLinkCriteria



    Exit_CmdBriefs_Click:
    Exit Sub

    Err_CmdBriefs_Click:
    MsgBox Err.Description
    Resume Exit_CmdBriefs_Click

    End Sub<hr>

    The other sets this control sets ChkVisible to -1. I original tried setting this to either True of False, but it kept displaying an error message.....

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

    Re: Hiding controls (2000)

    What kind of control is chkVisible?

  6. #6
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding controls (2000)

    ChkVisible is a check box.

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

    Re: Hiding controls (2000)

    In that case you should be able to set it to True or False. What was the error message you got?

  8. #8
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding controls (2000)

    This is the error message that is displayed:

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

    Re: Hiding controls (2000)

    Did you put something in the Control Source of the text box?

    It might be faster if you could post a stripped down copy of the database (zipped)

  10. #10
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding controls (2000)

    Heres a really stripped down version. The two main forms are the ones I'm having problems with. FrmMain followed by FrmRptMenu....
    The problem seems to be with the visibility of the controls in FrmRptMenu

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

    Re: Hiding controls (2000)

    Your frmRptMenu has a major problem: you have set the Visible property of its Detail section to No, so it doesn't matter how you set the Visible property of individual controls, they won't be visible anyway. You should set the Visible property of the Detail section to Yes.

    The code that sets ChkVisible to True or False on frmMain works without a problem.

    I think you set too many controls to invisible, but that is for you to decide.

  12. #12
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding controls (2000)

    I've missed this, thanks Hans.
    However I still can't get the appropriate controls to become hidden...............ahhhhhhhhhhhhh

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

    Re: Hiding controls (2000)

    See the attached version.

    Note: DO NOT copy the forms from this database to your own copy. I had to take out some things to be able to work with them (such as the code to prevent the forms from closing)

  14. #14
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding controls (2000)

    Still seem to be having problems with this blasted thing......................
    I'm trying to get the CmdRptExit command button to display through both selections.
    I've tried:
    <hr>
    Me.CmdRptExit.Visible = True
    <hr>
    Instead of Me.CmdRptExit.Visible=f, which only displays the Exit button when the user selects a certain control in FrmMain.
    However if I use Me.CmdRptExit.Visible = True, this makes everything invisible.
    I've also tried to not include CmdRptExit, in the vb..........but this doesn't work either.
    Am I being dense????? <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

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

    Re: Hiding controls (2000)

    Why don't you set the Visible property of cmdRptExit to Yes in design view? Since you want it to be visible in all situations, there is no need to use VBA code for it.

Page 1 of 2 12 LastLast

Posting Permissions

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