Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Aug 2001
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Disable/Enable Command button (Access 97)

    Can anyone help please...

    I have a command button on a form for GoToPrevious in order to navigate to the previous record. I'd like to have it so this button was disabled when I was viewing the first record (same as what happens with the navigation buttons at the bottom of the form). Does anyone know how to disable/enable such a command button using a macro (or whatever it takes)?

    Thanks.

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

    Re: Disable/Enable Command button (Access 97)

    You'll need code in the On Current event of the form, and inspect the CurrentRecord property of the form. This property corresponds to the record number as displayed at the bottm of the form (if the default navigation buttons are shown). It will be 1 if the user is viewing the first record.

    Private Sub Form_Current()
    cmdPrevious.Enabled = (Me.CurrentRecord > 1)
    End Sub

    Replace cmdPrevious with the name of your command button.

  3. #3
    New Lounger
    Join Date
    Aug 2001
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable/Enable Command button (Access 97)

    Thank you Hans!
    It works perfectly.

Posting Permissions

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