Applecore Pages on Microsoft Access

Replacing the Form's Navigation Buttons and Record Position

If you remove the form's navigation buttons, and replace them with your own, you might want to also include the current position of the form. To do this, you will need to add two text boxes to the form's footer, called txtCurrent and txtTotal, and then set the ControlSources in the OnCurrent event to:

Private Sub Form_Current()
    Me!txtCurrent = Me.CurrentRecord
    Me.RecordsetClone.MoveLast
    Me!txtTotal = Me.RecordsetClone.RecordCount
End Sub

If you also want to be able to type in a new number into this text box, and then go to that record, as you could previously, then you will need to use some code in the AfterUpdate event for the control:

Private Sub txtCurrent_AfterUpdate()
    If IsNumeric(Me!txtCurrent) Then
        If CLng(Me!txtCurrent) >= 0 And CLng(Me!txtCurrent) <= Me!txtTotal Then
            Me.RecordsetClone.AbsolutePosition = Me!txtCurrent - 1
            Me.Bookmark = Me.RecordsetClone.Bookmark
        Else
            Me!txtCurrent = Me.CurrentRecord
        End If
    Else
        Me!txtCurrent = Me.CurrentRecord
    End If
End Sub

Top

 


HOME | NEW | TABLES | QUERIES | FORMS | REPORTS | GENERAL | API | DOWNLOADS | TUTORIAL | RESOURCES
E-MAIL
Copyright & Disclaimer

 

Last modified at 06/06/2006 14:54:53