Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Apr 2008
    Posts
    188
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Navigation Buttons on a form

    I am trying to open a form in two different ways.

    If I open the form "frmStudentMasterForm" so that it goes to a specific record I do not want the navigation buttons at the bottom of the screen to appear.

    If I open the same form so that you can scroll through all the records I want the navigation buttons to appear.

    How can I code this so that the navigation buttons will appear/not appear depending on how I open the form?

    Thanks.

    Paul

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Paul,

    Here's one option.

    Set up a Public variable bNavigation as boolean.

    Code to open form:
    Code:
    Public bNavigation As Boolean
    
    Sub Run_frmTabTest()
    
      bNavigation = False  '*** No Navigation Buttons ***
      DoCmd.OpenForm "frmTabTest", acNormal
      
    End Sub
    Of course you already have code to open the form it either of the two modes you just need to set bNavigation to the appropriate value.

    In your form code add:

    Code:
    Private Sub Form_Load()
    
       Me.NavigationButtons = bNavigation
       
    End Sub
    Last edited by RetiredGeek; 2011-01-31 at 08:04.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    Another option is to check the Record Count in the On Load event.

    Code:
           Dim rs As Object
            Set rs = Me.RecordsetClone
            rs.MoveLast
            ' to be sure it gets the coutn right
            me.NavigationButtons= (rs.RecordCount>1)
    Regards
    John



  4. #4
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    John,

    Very nice!
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

Posting Permissions

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