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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top