Changing the enabled value for a command button.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need a button to have enabled = false if the record is not the last one.
(eg If there are 26 records and the user is on record 26 then the button can
be used. If the user is on record 14 then the button can not be used.) I
know how to change the value, but don't know how to tell what the record
number is. Can anyone help me?
 
I need a button to have enabled = false if the record is not the last one.
(eg If there are 26 records and the user is on record 26 then the button can
be used. If the user is on record 14 then the button can not be used.) I
know how to change the value, but don't know how to tell what the record
number is. Can anyone help me?
CurrentRecord is the Form's current record number.
Recordset.RecordCount is the total number of records in the form's
recordset.

CommandButtonName.Enabled = Me.CurrentRecord =
Me.Recordset.RecordCount
 
James said:
I need a button to have enabled = false if the record is not the last one.
(eg If there are 26 records and the user is on record 26 then the button can
be used. If the user is on record 14 then the button can not be used.) I
know how to change the value, but don't know how to tell what the record
number is.


Try this:

With Me.RecordsetClone
.MoveLast
Me.yourbutton.Enabled = (.RecordCount = Me.CurrentRecord)
End With
 
Thank you for your help.

It works, but but I had to make it >= incase it was a new record.
 
Back
Top