Help with code

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

    #1

    Help with code

    Hi all,
    I am trying to learn a little about programming (I know next to nothing
    so far) and have found some code which hides the toolbars. However, this bit
    of code is a little too effective and hides all of them including hiding the
    database window, disabling menu changes. What I am after is the same effect
    as disabling all the check boxes in startup which still leaves 'File',
    'Edit', 'Insert','Recor ds','Window' &'Help'. I want to do this via code so
    that with a click of a button, I can show them again from a protected form.
    This cannot be done though when the boxes are unchecked from startup.

    Here is the code I have.

    Private Sub Form_Open(Cance l As Integer)
    Dim l As Integer
    For l = 1 To CommandBars.Cou nt
    CommandBars(l). Enabled = False
    Next l
    DoCmd.SelectObj ect acTable, , True
    DoCmd.RunComman d acCmdWindowHide
    DoCmd.ShowToolb ar "Web", acToolbarNo
    End Sub

    Any help with this would be much appreciated :o)

    Mark


  • Mr. Smith

    #2
    Re: Help with code

    Mark Reed wrote:[color=blue]
    > Hi all,
    > I am trying to learn a little about programming (I know next to nothing
    > so far) and have found some code which hides the toolbars. However, this bit
    > of code is a little too effective and hides all of them including hiding the
    > database window, disabling menu changes. What I am after is the same effect
    > as disabling all the check boxes in startup which still leaves 'File',
    > 'Edit', 'Insert','Recor ds','Window' &'Help'. I want to do this via code so
    > that with a click of a button, I can show them again from a protected form.
    > This cannot be done though when the boxes are unchecked from startup.
    >
    > Here is the code I have.
    >
    > Private Sub Form_Open(Cance l As Integer)
    > Dim l As Integer
    > For l = 1 To CommandBars.Cou nt
    > CommandBars(l). Enabled = False
    > Next l
    > DoCmd.SelectObj ect acTable, , True
    > DoCmd.RunComman d acCmdWindowHide
    > DoCmd.ShowToolb ar "Web", acToolbarNo
    > End Sub
    >
    > Any help with this would be much appreciated :o)
    >
    > Mark
    >
    >[/color]

    This is how you control what gets effected. You test the name of each
    Commandbar as you loop through them all using the 'If' statement.

    In the code below the If statement asks the question 'If the name of the
    CommandBars(l) is not equal to (<>) "Menu Bar" then set the enabled
    property of Commandbars(l) to false". Because there is no 'else'
    statement following this, nothing will happen when if the name of the
    command bar being tested IS "Menu bar" IE. it will NOT be disabled.


    Private Sub Form_Open(Cance l As Integer)
    Dim l As Integer
    For l = 1 To CommandBars.Cou nt
    IF CommandBars.Nam e <> "Menu bar" then CommandBars(l). Enabled =
    False
    Next l
    DoCmd.SelectObj ect acTable, , True
    DoCmd.RunComman d acCmdWindowHide
    DoCmd.ShowToolb ar "Web", acToolbarNo
    End Sub

    HTH
    Mr. Smith

    Comment

    • Mark Reed

      #3
      Re: Help with code

      Hi Mr Smith,
      Thanks for your help however, when I run the code from a command button
      I get the following error:
      Compile error: method or data member not found.
      the following line is highlighted: If CommandBars.Nam e

      Could you shed any light on this?

      Many thanks for your time,


      Mark

      "Mr. Smith" <Mr.Smith@Large > wrote in message
      news:40d7f980$0 $29880$61ce578d @news.syd.swift dsl.com.au...[color=blue]
      > Mark Reed wrote:[color=green]
      > > Hi all,
      > > I am trying to learn a little about programming (I know next to[/color][/color]
      nothing[color=blue][color=green]
      > > so far) and have found some code which hides the toolbars. However, this[/color][/color]
      bit[color=blue][color=green]
      > > of code is a little too effective and hides all of them including hiding[/color][/color]
      the[color=blue][color=green]
      > > database window, disabling menu changes. What I am after is the same[/color][/color]
      effect[color=blue][color=green]
      > > as disabling all the check boxes in startup which still leaves 'File',
      > > 'Edit', 'Insert','Recor ds','Window' &'Help'. I want to do this via code[/color][/color]
      so[color=blue][color=green]
      > > that with a click of a button, I can show them again from a protected[/color][/color]
      form.[color=blue][color=green]
      > > This cannot be done though when the boxes are unchecked from startup.
      > >
      > > Here is the code I have.
      > >
      > > Private Sub Form_Open(Cance l As Integer)
      > > Dim l As Integer
      > > For l = 1 To CommandBars.Cou nt
      > > CommandBars(l). Enabled = False
      > > Next l
      > > DoCmd.SelectObj ect acTable, , True
      > > DoCmd.RunComman d acCmdWindowHide
      > > DoCmd.ShowToolb ar "Web", acToolbarNo
      > > End Sub
      > >
      > > Any help with this would be much appreciated :o)
      > >
      > > Mark
      > >
      > >[/color]
      >
      > This is how you control what gets effected. You test the name of each
      > Commandbar as you loop through them all using the 'If' statement.
      >
      > In the code below the If statement asks the question 'If the name of the
      > CommandBars(l) is not equal to (<>) "Menu Bar" then set the enabled
      > property of Commandbars(l) to false". Because there is no 'else'
      > statement following this, nothing will happen when if the name of the
      > command bar being tested IS "Menu bar" IE. it will NOT be disabled.
      >
      >
      > Private Sub Form_Open(Cance l As Integer)
      > Dim l As Integer
      > For l = 1 To CommandBars.Cou nt
      > IF CommandBars.Nam e <> "Menu bar" then CommandBars(l). Enabled =
      > False
      > Next l
      > DoCmd.SelectObj ect acTable, , True
      > DoCmd.RunComman d acCmdWindowHide
      > DoCmd.ShowToolb ar "Web", acToolbarNo
      > End Sub
      >
      > HTH
      > Mr. Smith[/color]


      Comment

      • Mr. Smith

        #4
        Re: Help with code


        Sorry, my bad.

        Try this: If CommandBars(l). Name ....
        ^^^

        We MUST stipulate which iteration of the CommandBars 'collection' (as it
        is known) is being tested.



        Mark Reed wrote:[color=blue]
        > Hi Mr Smith,
        > Thanks for your help however, when I run the code from a command button
        > I get the following error:
        > Compile error: method or data member not found.
        > the following line is highlighted: If CommandBars.Nam e
        >
        > Could you shed any light on this?
        >
        > Many thanks for your time,
        >
        >
        > Mark
        >
        > "Mr. Smith" <Mr.Smith@Large > wrote in message
        > news:40d7f980$0 $29880$61ce578d @news.syd.swift dsl.com.au...
        >[color=green]
        >>Mark Reed wrote:
        >>[color=darkred]
        >>>Hi all,
        >>> I am trying to learn a little about programming (I know next to[/color][/color]
        >
        > nothing
        >[color=green][color=darkred]
        >>>so far) and have found some code which hides the toolbars. However, this[/color][/color]
        >
        > bit
        >[color=green][color=darkred]
        >>>of code is a little too effective and hides all of them including hiding[/color][/color]
        >
        > the
        >[color=green][color=darkred]
        >>>database window, disabling menu changes. What I am after is the same[/color][/color]
        >
        > effect
        >[color=green][color=darkred]
        >>>as disabling all the check boxes in startup which still leaves 'File',
        >>>'Edit', 'Insert','Recor ds','Window' &'Help'. I want to do this via code[/color][/color]
        >
        > so
        >[color=green][color=darkred]
        >>>that with a click of a button, I can show them again from a protected[/color][/color]
        >
        > form.
        >[color=green][color=darkred]
        >>>This cannot be done though when the boxes are unchecked from startup.
        >>>
        >>>Here is the code I have.
        >>>
        >>>Private Sub Form_Open(Cance l As Integer)
        >>> Dim l As Integer
        >>> For l = 1 To CommandBars.Cou nt
        >>> CommandBars(l). Enabled = False
        >>> Next l
        >>> DoCmd.SelectObj ect acTable, , True
        >>> DoCmd.RunComman d acCmdWindowHide
        >>> DoCmd.ShowToolb ar "Web", acToolbarNo
        >>>End Sub
        >>>
        >>>Any help with this would be much appreciated :o)
        >>>
        >>>Mark
        >>>
        >>>[/color]
        >>
        >>This is how you control what gets effected. You test the name of each
        >>Commandbar as you loop through them all using the 'If' statement.
        >>
        >>In the code below the If statement asks the question 'If the name of the
        >>CommandBars(l ) is not equal to (<>) "Menu Bar" then set the enabled
        >>property of Commandbars(l) to false". Because there is no 'else'
        >>statement following this, nothing will happen when if the name of the
        >>command bar being tested IS "Menu bar" IE. it will NOT be disabled.
        >>
        >>
        >>Private Sub Form_Open(Cance l As Integer)
        >> Dim l As Integer
        >> For l = 1 To CommandBars.Cou nt
        >> IF CommandBars.Nam e <> "Menu bar" then CommandBars(l). Enabled =
        >>False
        >> Next l
        >> DoCmd.SelectObj ect acTable, , True
        >> DoCmd.RunComman d acCmdWindowHide
        >> DoCmd.ShowToolb ar "Web", acToolbarNo
        >>End Sub
        >>
        >>HTH
        >>Mr. Smith[/color]
        >
        >
        >[/color]

        Comment

        • Mark Reed

          #5
          Re: Help with code

          Hi Again,
          Sorry to be a pain. I have changed the code as you suggested and it runs
          with no errors. Unfortunately, the menu bar is still hidden. I have read
          through your posts and I understand what it is doing (to a degree) and
          cannot understand what is going wrong......

          Just incase I am still doing something wrong, here is the code as it is now:

          Private Sub Form_Open(Cance l As Integer)
          Dim l As Integer
          For l = 1 To CommandBars.Cou nt
          If CommandBars(1). Name <> "Menu Bar" Then CommandBars(l). Enabled =
          False
          Next l
          DoCmd.SelectObj ect acTable, , True
          DoCmd.RunComman d acCmdWindowHide
          DoCmd.ShowToolb ar "Web", acToolbarNo
          End Sub

          I really appreciate your help on this,

          Mark

          "Mr. Smith" <Mr.Smith@Large > wrote in message
          news:40d8bc4a$0 $29887$61ce578d @news.syd.swift dsl.com.au...[color=blue]
          >
          > Sorry, my bad.
          >
          > Try this: If CommandBars(l). Name ....
          > ^^^
          >
          > We MUST stipulate which iteration of the CommandBars 'collection' (as it
          > is known) is being tested.
          >
          >
          >
          > Mark Reed wrote:[color=green]
          > > Hi Mr Smith,
          > > Thanks for your help however, when I run the code from a command[/color][/color]
          button[color=blue][color=green]
          > > I get the following error:
          > > Compile error: method or data member not found.
          > > the following line is highlighted: If CommandBars.Nam e
          > >
          > > Could you shed any light on this?
          > >
          > > Many thanks for your time,
          > >
          > >
          > > Mark
          > >
          > > "Mr. Smith" <Mr.Smith@Large > wrote in message
          > > news:40d7f980$0 $29880$61ce578d @news.syd.swift dsl.com.au...
          > >[color=darkred]
          > >>Mark Reed wrote:
          > >>
          > >>>Hi all,
          > >>> I am trying to learn a little about programming (I know next to[/color]
          > >
          > > nothing
          > >[color=darkred]
          > >>>so far) and have found some code which hides the toolbars. However,[/color][/color][/color]
          this[color=blue][color=green]
          > >
          > > bit
          > >[color=darkred]
          > >>>of code is a little too effective and hides all of them including[/color][/color][/color]
          hiding[color=blue][color=green]
          > >
          > > the
          > >[color=darkred]
          > >>>database window, disabling menu changes. What I am after is the same[/color]
          > >
          > > effect
          > >[color=darkred]
          > >>>as disabling all the check boxes in startup which still leaves 'File',
          > >>>'Edit', 'Insert','Recor ds','Window' &'Help'. I want to do this via code[/color]
          > >
          > > so
          > >[color=darkred]
          > >>>that with a click of a button, I can show them again from a protected[/color]
          > >
          > > form.
          > >[color=darkred]
          > >>>This cannot be done though when the boxes are unchecked from startup.
          > >>>
          > >>>Here is the code I have.
          > >>>
          > >>>Private Sub Form_Open(Cance l As Integer)
          > >>> Dim l As Integer
          > >>> For l = 1 To CommandBars.Cou nt
          > >>> CommandBars(l). Enabled = False
          > >>> Next l
          > >>> DoCmd.SelectObj ect acTable, , True
          > >>> DoCmd.RunComman d acCmdWindowHide
          > >>> DoCmd.ShowToolb ar "Web", acToolbarNo
          > >>>End Sub
          > >>>
          > >>>Any help with this would be much appreciated :o)
          > >>>
          > >>>Mark
          > >>>
          > >>>
          > >>
          > >>This is how you control what gets effected. You test the name of each
          > >>Commandbar as you loop through them all using the 'If' statement.
          > >>
          > >>In the code below the If statement asks the question 'If the name of the
          > >>CommandBars(l ) is not equal to (<>) "Menu Bar" then set the enabled
          > >>property of Commandbars(l) to false". Because there is no 'else'
          > >>statement following this, nothing will happen when if the name of the
          > >>command bar being tested IS "Menu bar" IE. it will NOT be disabled.
          > >>
          > >>
          > >>Private Sub Form_Open(Cance l As Integer)
          > >> Dim l As Integer
          > >> For l = 1 To CommandBars.Cou nt
          > >> IF CommandBars.Nam e <> "Menu bar" then CommandBars(l). Enabled =
          > >>False
          > >> Next l
          > >> DoCmd.SelectObj ect acTable, , True
          > >> DoCmd.RunComman d acCmdWindowHide
          > >> DoCmd.ShowToolb ar "Web", acToolbarNo
          > >>End Sub
          > >>
          > >>HTH
          > >>Mr. Smith[/color]
          > >
          > >
          > >[/color][/color]


          Comment

          • Mr. Smith

            #6
            Re: Help with code


            Sorry, I just flicked thourgh a brief test to give you some code to work
            with and didn't chekc the results as thoroughly as I should have.

            What you can do to test/see what is happening is this. In your For l =
            1 To CommandBars.Cou nt code, enter the line;

            Debug.print CommandBars(1). Name

            so you have

            For l = 1 To CommandBars.Cou nt
            Debug.print CommandBars(1). Name
            If CommandBars(1). Name <> "Menu Bar" Then
            CommandBars(l). Enabled = False
            Next l

            Then, in your VBA window, select 'View' menu -> Immediate Window

            Next place your cursor on the line

            Private Sub Form_Open(Cance l As Integer)

            and pres F9. This sets breakpoint which halts execution of the code to
            help you 'watch' what is taking place. Now open your form from the
            database window and you will se that the line;

            Private Sub Form_Open(Cance l As Integer)

            will be highlighted in yellow. Now press the F8 key to 'step' through
            the code one line at a time. When the line;

            Debug.print CommandBars(1). Name

            is higlighted and you then press F8, you will see the name of th
            CommandbBar currently being processed in the Immediate Window we opened
            earlier. The line

            If CommandBars(1). Name <> "Menu Bar" Then CommandBars(l). Enabled =
            False

            will now be higlighted. Press F8 once, then Alt-Tab to the main Access
            window to see if the menu you want to retain has been removed. If it
            has, the name of that menu bar will be the last one to appear in the
            Immediate Window. You can the add this name to your 'IF' statement. So
            where we currently have;

            If CommandBars(1). Name <> "Menu Bar" Then...

            you add any extra conditions as follows

            If CommandBars(1). Name <> "Menu Bar" AND _
            CommandBars(1). Name <> "Other menus bar name 1" AND _
            CommandBars(1). Name <> "Other menus bar name 2" Then

            And so on.

            Hopefully this should equip you with an understanding as to how to
            decifer the results you need for yourself. If not just reply back. I'm
            only too happy to help.

            Good Luck,
            Mr. Smith.

            PS: Do you use Windows XP?


            Mark Reed wrote:[color=blue]
            > Hi Again,
            > Sorry to be a pain. I have changed the code as you suggested and it runs
            > with no errors. Unfortunately, the menu bar is still hidden. I have read
            > through your posts and I understand what it is doing (to a degree) and
            > cannot understand what is going wrong......
            >
            > Just incase I am still doing something wrong, here is the code as it is now:
            >
            > Private Sub Form_Open(Cance l As Integer)
            > Dim l As Integer
            > For l = 1 To CommandBars.Cou nt
            > If CommandBars(1). Name <> "Menu Bar" Then CommandBars(l). Enabled =
            > False
            > Next l
            > DoCmd.SelectObj ect acTable, , True
            > DoCmd.RunComman d acCmdWindowHide
            > DoCmd.ShowToolb ar "Web", acToolbarNo
            > End Sub
            >
            > I really appreciate your help on this,
            >
            > Mark
            >
            > "Mr. Smith" <Mr.Smith@Large > wrote in message
            > news:40d8bc4a$0 $29887$61ce578d @news.syd.swift dsl.com.au...
            >[color=green]
            >>Sorry, my bad.
            >>
            >>Try this: If CommandBars(l). Name ....
            >> ^^^
            >>
            >>We MUST stipulate which iteration of the CommandBars 'collection' (as it
            >>is known) is being tested.
            >>
            >>
            >>
            >>Mark Reed wrote:
            >>[color=darkred]
            >>>Hi Mr Smith,
            >>> Thanks for your help however, when I run the code from a command[/color][/color]
            >
            > button
            >[color=green][color=darkred]
            >>>I get the following error:
            >>>Compile error: method or data member not found.
            >>>the following line is highlighted: If CommandBars.Nam e
            >>>
            >>>Could you shed any light on this?
            >>>
            >>>Many thanks for your time,
            >>>
            >>>
            >>>Mark
            >>>
            >>>"Mr. Smith" <Mr.Smith@Large > wrote in message
            >>>news:40d7f98 0$0$29880$61ce5 78d@news.syd.sw iftdsl.com.au.. .
            >>>
            >>>
            >>>>Mark Reed wrote:
            >>>>
            >>>>
            >>>>>Hi all,
            >>>>> I am trying to learn a little about programming (I know next to
            >>>
            >>>nothing
            >>>
            >>>
            >>>>>so far) and have found some code which hides the toolbars. However,[/color][/color]
            >
            > this
            >[color=green][color=darkred]
            >>>bit
            >>>
            >>>
            >>>>>of code is a little too effective and hides all of them including[/color][/color]
            >
            > hiding
            >[color=green][color=darkred]
            >>>the
            >>>
            >>>
            >>>>>database window, disabling menu changes. What I am after is the same
            >>>
            >>>effect
            >>>
            >>>
            >>>>>as disabling all the check boxes in startup which still leaves 'File',
            >>>>>'Edit', 'Insert','Recor ds','Window' &'Help'. I want to do this via code
            >>>
            >>>so
            >>>
            >>>
            >>>>>that with a click of a button, I can show them again from a protected
            >>>
            >>>form.
            >>>
            >>>
            >>>>>This cannot be done though when the boxes are unchecked from startup.
            >>>>>
            >>>>>Here is the code I have.
            >>>>>
            >>>>>Private Sub Form_Open(Cance l As Integer)
            >>>>> Dim l As Integer
            >>>>> For l = 1 To CommandBars.Cou nt
            >>>>> CommandBars(l). Enabled = False
            >>>>> Next l
            >>>>> DoCmd.SelectObj ect acTable, , True
            >>>>> DoCmd.RunComman d acCmdWindowHide
            >>>>> DoCmd.ShowToolb ar "Web", acToolbarNo
            >>>>>End Sub
            >>>>>
            >>>>>Any help with this would be much appreciated :o)
            >>>>>
            >>>>>Mark
            >>>>>
            >>>>>
            >>>>
            >>>>This is how you control what gets effected. You test the name of each
            >>>>Commandba r as you loop through them all using the 'If' statement.
            >>>>
            >>>>In the code below the If statement asks the question 'If the name of the
            >>>>CommandBars (l) is not equal to (<>) "Menu Bar" then set the enabled
            >>>>property of Commandbars(l) to false". Because there is no 'else'
            >>>>statement following this, nothing will happen when if the name of the
            >>>>command bar being tested IS "Menu bar" IE. it will NOT be disabled.
            >>>>
            >>>>
            >>>>Private Sub Form_Open(Cance l As Integer)
            >>>> Dim l As Integer
            >>>> For l = 1 To CommandBars.Cou nt
            >>>> IF CommandBars.Nam e <> "Menu bar" then CommandBars(l). Enabled =
            >>>>False
            >>>> Next l
            >>>> DoCmd.SelectObj ect acTable, , True
            >>>> DoCmd.RunComman d acCmdWindowHide
            >>>> DoCmd.ShowToolb ar "Web", acToolbarNo
            >>>>End Sub
            >>>>
            >>>>HTH
            >>>>Mr. Smith
            >>>
            >>>
            >>>[/color][/color]
            >
            >[/color]

            Comment

            • Mark Reed

              #7
              Re: Help with code

              Hi again,
              I have followed your instructions and I am a little confused. After
              going through each step of the code, the only thing to appear in the
              immediate window is "Task Pane". I have changed the line "If
              CommandBars(1). Name <> "Menu Bar" Then" to read "If CommandBars(1). Name <>
              "Task Pane" Then" and run it again and the menu stays visible.

              This shows that the code is working OK but I was hoping to see a list of all
              the command bars. With the task pane visible, I can still use too many
              functions from the menu and not the same as when I disable the menus from
              startup :-( Any ideas?

              Thanks again for your help and explaining in novice terms what your going on
              about. It's a great help learning what exactly it is I'm typing.

              Regards,

              Mark

              "Mr. Smith" <Mr.Smith@Large > wrote in message
              news:40da0ffe$0 $29887$61ce578d @news.syd.swift dsl.com.au...[color=blue]
              >
              > Sorry, I just flicked thourgh a brief test to give you some code to work
              > with and didn't chekc the results as thoroughly as I should have.
              >
              > What you can do to test/see what is happening is this. In your For l =
              > 1 To CommandBars.Cou nt code, enter the line;
              >
              > Debug.print CommandBars(1). Name
              >
              > so you have
              >
              > For l = 1 To CommandBars.Cou nt
              > Debug.print CommandBars(1). Name
              > If CommandBars(1). Name <> "Menu Bar" Then
              > CommandBars(l). Enabled = False
              > Next l
              >
              > Then, in your VBA window, select 'View' menu -> Immediate Window
              >
              > Next place your cursor on the line
              >
              > Private Sub Form_Open(Cance l As Integer)
              >
              > and pres F9. This sets breakpoint which halts execution of the code to
              > help you 'watch' what is taking place. Now open your form from the
              > database window and you will se that the line;
              >
              > Private Sub Form_Open(Cance l As Integer)
              >
              > will be highlighted in yellow. Now press the F8 key to 'step' through
              > the code one line at a time. When the line;
              >
              > Debug.print CommandBars(1). Name
              >
              > is higlighted and you then press F8, you will see the name of th
              > CommandbBar currently being processed in the Immediate Window we opened
              > earlier. The line
              >
              > If CommandBars(1). Name <> "Menu Bar" Then CommandBars(l). Enabled =
              > False
              >
              > will now be higlighted. Press F8 once, then Alt-Tab to the main Access
              > window to see if the menu you want to retain has been removed. If it
              > has, the name of that menu bar will be the last one to appear in the
              > Immediate Window. You can the add this name to your 'IF' statement. So
              > where we currently have;
              >
              > If CommandBars(1). Name <> "Menu Bar" Then...
              >
              > you add any extra conditions as follows
              >
              > If CommandBars(1). Name <> "Menu Bar" AND _
              > CommandBars(1). Name <> "Other menus bar name 1" AND _
              > CommandBars(1). Name <> "Other menus bar name 2" Then
              >
              > And so on.
              >
              > Hopefully this should equip you with an understanding as to how to
              > decifer the results you need for yourself. If not just reply back. I'm
              > only too happy to help.
              >
              > Good Luck,
              > Mr. Smith.
              >
              > PS: Do you use Windows XP?
              >
              >
              > Mark Reed wrote:[color=green]
              > > Hi Again,
              > > Sorry to be a pain. I have changed the code as you suggested and it[/color][/color]
              runs[color=blue][color=green]
              > > with no errors. Unfortunately, the menu bar is still hidden. I have read
              > > through your posts and I understand what it is doing (to a degree) and
              > > cannot understand what is going wrong......
              > >
              > > Just incase I am still doing something wrong, here is the code as it is[/color][/color]
              now:[color=blue][color=green]
              > >
              > > Private Sub Form_Open(Cance l As Integer)
              > > Dim l As Integer
              > > For l = 1 To CommandBars.Cou nt
              > > If CommandBars(1). Name <> "Menu Bar" Then CommandBars(l). Enabled =
              > > False
              > > Next l
              > > DoCmd.SelectObj ect acTable, , True
              > > DoCmd.RunComman d acCmdWindowHide
              > > DoCmd.ShowToolb ar "Web", acToolbarNo
              > > End Sub
              > >
              > > I really appreciate your help on this,
              > >
              > > Mark
              > >
              > > "Mr. Smith" <Mr.Smith@Large > wrote in message
              > > news:40d8bc4a$0 $29887$61ce578d @news.syd.swift dsl.com.au...
              > >[color=darkred]
              > >>Sorry, my bad.
              > >>
              > >>Try this: If CommandBars(l). Name ....
              > >> ^^^
              > >>
              > >>We MUST stipulate which iteration of the CommandBars 'collection' (as it
              > >>is known) is being tested.
              > >>
              > >>
              > >>
              > >>Mark Reed wrote:
              > >>
              > >>>Hi Mr Smith,
              > >>> Thanks for your help however, when I run the code from a command[/color]
              > >
              > > button
              > >[color=darkred]
              > >>>I get the following error:
              > >>>Compile error: method or data member not found.
              > >>>the following line is highlighted: If CommandBars.Nam e
              > >>>
              > >>>Could you shed any light on this?
              > >>>
              > >>>Many thanks for your time,
              > >>>
              > >>>
              > >>>Mark
              > >>>
              > >>>"Mr. Smith" <Mr.Smith@Large > wrote in message
              > >>>news:40d7f98 0$0$29880$61ce5 78d@news.syd.sw iftdsl.com.au.. .
              > >>>
              > >>>
              > >>>>Mark Reed wrote:
              > >>>>
              > >>>>
              > >>>>>Hi all,
              > >>>>> I am trying to learn a little about programming (I know next to
              > >>>
              > >>>nothing
              > >>>
              > >>>
              > >>>>>so far) and have found some code which hides the toolbars. However,[/color]
              > >
              > > this
              > >[color=darkred]
              > >>>bit
              > >>>
              > >>>
              > >>>>>of code is a little too effective and hides all of them including[/color]
              > >
              > > hiding
              > >[color=darkred]
              > >>>the
              > >>>
              > >>>
              > >>>>>database window, disabling menu changes. What I am after is the same
              > >>>
              > >>>effect
              > >>>
              > >>>
              > >>>>>as disabling all the check boxes in startup which still leaves[/color][/color][/color]
              'File',[color=blue][color=green][color=darkred]
              > >>>>>'Edit', 'Insert','Recor ds','Window' &'Help'. I want to do this via[/color][/color][/color]
              code[color=blue][color=green][color=darkred]
              > >>>
              > >>>so
              > >>>
              > >>>
              > >>>>>that with a click of a button, I can show them again from a protected
              > >>>
              > >>>form.
              > >>>
              > >>>
              > >>>>>This cannot be done though when the boxes are unchecked from startup.
              > >>>>>
              > >>>>>Here is the code I have.
              > >>>>>
              > >>>>>Private Sub Form_Open(Cance l As Integer)
              > >>>>> Dim l As Integer
              > >>>>> For l = 1 To CommandBars.Cou nt
              > >>>>> CommandBars(l). Enabled = False
              > >>>>> Next l
              > >>>>> DoCmd.SelectObj ect acTable, , True
              > >>>>> DoCmd.RunComman d acCmdWindowHide
              > >>>>> DoCmd.ShowToolb ar "Web", acToolbarNo
              > >>>>>End Sub
              > >>>>>
              > >>>>>Any help with this would be much appreciated :o)
              > >>>>>
              > >>>>>Mark
              > >>>>>
              > >>>>>
              > >>>>
              > >>>>This is how you control what gets effected. You test the name of each
              > >>>>Commandba r as you loop through them all using the 'If' statement.
              > >>>>
              > >>>>In the code below the If statement asks the question 'If the name of[/color][/color][/color]
              the[color=blue][color=green][color=darkred]
              > >>>>CommandBars (l) is not equal to (<>) "Menu Bar" then set the enabled
              > >>>>property of Commandbars(l) to false". Because there is no 'else'
              > >>>>statement following this, nothing will happen when if the name of the
              > >>>>command bar being tested IS "Menu bar" IE. it will NOT be disabled.
              > >>>>
              > >>>>
              > >>>>Private Sub Form_Open(Cance l As Integer)
              > >>>> Dim l As Integer
              > >>>> For l = 1 To CommandBars.Cou nt
              > >>>> IF CommandBars.Nam e <> "Menu bar" then CommandBars(l). Enabled[/color][/color][/color]
              =[color=blue][color=green][color=darkred]
              > >>>>False
              > >>>> Next l
              > >>>> DoCmd.SelectObj ect acTable, , True
              > >>>> DoCmd.RunComman d acCmdWindowHide
              > >>>> DoCmd.ShowToolb ar "Web", acToolbarNo
              > >>>>End Sub
              > >>>>
              > >>>>HTH
              > >>>>Mr. Smith
              > >>>
              > >>>
              > >>>[/color]
              > >
              > >[/color][/color]


              Comment

              Working...