Making navigation buttons disappear

  • Thread starter Thread starter Paul Henderson
  • Start date Start date
P

Paul Henderson

I have a form which displays records and has custom
navigation command buttons on it. I would like the 'Next'
button to disappear when I get to the end of a record set
and before I get the standard warning message. How can I
do this? I understand that it has to do with recordsets,
but my amateur efforts with VBA have so far failed.
 
Somebody here provided me with this code (cmdPrevious and
cmdNext are the naviagation buttons):
cmdPrevious.Visible = Not Me.CurrentRecord = 1
cmdNext.Visible = (Me.CurrentRecord = 1 And_
Me.Recordset.RecordCount > 1) Or Me.CurrentRecord_
< Me.Recordset.RecordCount
(The underscores indicate no line break)
You could substitute Enabled for Visible to gray out
rather than hide the navigation buttons.
 
Paul,

You can put the following code in the Current event of your Form:

Me.RecordsetClone.MoveLast
cmdPrevious.Visible = Not Me.CurrentRecord = 1
cmdNext.Visible = Not Me.CurrentRecord = Me.RecordsetClone.RecordCount


hth,
 
Try this in the Current event of the form:

If Me.Recordset.RecordCount - 1 = Me.Recordset.AbsolutePositon Then
Me.cmdNext.Enabled = False
Else
Me.cmdNext.Enabled = True
End If

This will disable the button. To hide it, change Enabled to Visible. The
AbsolutePosition property is zero based, that is the reason for subtracting
1.
 
Back
Top