Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordcount

Status
Not open for further replies.

vols77

Technical User
Feb 17, 2007
29
US
What is wrong with the below?

If RecordCount < 2 Then
Me.Command44.Enabled = False
Else
DoCmd.GoToRecord , , acPrevious
End If

Basically I am wanting to disable the button if there are fewer than 1 record (to avoid the "debug" error if there are no records and someone clicks the button)

I will then inturn modify this for the "Next record" button for when there is only 1 record.

Also, if anyone knows of a way to build a button to take the place of the Page up and page down buttons on the keyboard, that would be great as well.
 
To get an accurate record count, Access must read through the entire recordset. So
Dim TotalRecords
Set Records = Me.RecordsetClone
Records.MoveLast
TotalRecords = Records.RecordCount
If Totalrecords < 2
etc.
 
How about If rs.BOF And rs.EOF Then... ?
If there are no records, both will evaluate to True.

When everything is coming your way, you're in the wrong lane.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top