Home > Mobile >  How to make a button greyed out FOREVER in MS Access
How to make a button greyed out FOREVER in MS Access

Time:05-21

What I am trying to accomplish is this: Make a button for End Time which greys out once it is clicked. When moving to a new or the next record the button appears not greyed out, but will grey out once clicked. However, when I move to the new record, the button previously clicked in the previous records appear once again. Below is my code for the on-click function of the button:

Private Sub Command28_Click()
txtEndTime = Time()
Command28.Enabled = False
End Sub

I have also written this code for the Form_Current function:

Private Sub Form_Current()
    If Me.NewRecord Then
        Me.Command28.Enabled = True
    End If
End Sub

Any help would be greatly appreciated.

CodePudding user response:

Try with:

Private Sub Form_Current()
    Me!Command28.Enabled = Me.NewRecord
End Sub

And do rename it to something meaningful.

  • Related