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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Intelligent Navigation Buttons for forms 1

Status
Not open for further replies.

nayfeh

Programmer
Mar 13, 2002
163
CA
Hi,

Do you know where I can find code for intelligent navigation buttons? For example, when the user is at a new record in a form, then 'NEXT' button is disabled, and when they are at the start of the recordset, the 'First' button is disabled.

Any help is appreciated.

Thanks!
 
A utility subprogram that will do all “intelligent” record navigation buttons for any form

Public Funtion SmartNav(cmdFirst As CommandButton, cmdPrev As CommandButton, _
cmdNext As CommandButton, cmdLast As CommandButton)

Dim frm As Form

'Set object reference to form
Set frm = cmdFirst.Parent

'Check for no records
If frm.RecordsetClone.RecordCount <> 0 Then
frm.RecordsetClone.MoveLast
frm.RecordsetClone.MoveFirst

'Check for first record
If frm.CurrentRecord = 1 Then
cmdPrev.Enabled = False
cmdFirst.Enabled = False
Else
cmdPrev.Enabled = True
cmdFirst.Enabled = True
End If

'Check for last record
If frm.CurrentRecord = frm.RecordsetClone.RecordCount Then
cmdNext.Enabled = False
cmdLast.Enabled = False
Else
cmdNext.Enabled = True
cmdLast.Enabled = True
End If

Else
cmdFirst.Enabled = False
cmdPrev.Enabled = False
cmdNext.Enabled = False
cmdLast.Enabled = False
End If

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top