I have this procedure:
Code:
Public Sub ViewData(strDirection)
'called by forms used to view and navigate records
If Not IsNull(Form_SampleInfo.tbxViewDataFormNAME) Then
DoCmd.Close acForm, Form_SampleInfo.tbxViewDataFormNAME, acSaveNo
End If
With Form_SampleInfo
.RecordsetClone.Bookmark = .Bookmark
Select Case strDirection
Case "Quit"
DoCmd.Close acForm, "SampleInfo", acSaveNo
Case "Next"
.RecordsetClone.MoveNext
If Not .RecordsetClone.EOF Then
DoCmd.GoToRecord acForm, "SampleInfo", acNext
Else
.RecordsetClone.MoveLast
MsgBox "Last record."
.btnNext.Enabled = False
End If
.btnPrevious.Enabled = True
Case "Previous"
.RecordsetClone.MovePrevious
If Not .RecordsetClone.BOF Then
DoCmd.GoToRecord acForm, "SampleInfo", acPrevious
Else
.RecordsetClone.MoveFirst
MsgBox "First record."
.btnPrevious.Enabled = False
End If
.btnNext.Enabled = True
End Select
End With
End Sub
One example of calling:
Code:
Private Sub btnNext_Click()
Me.btnViewLabData.SetFocus
Call ViewData("Next")
End Sub
It's been so long since I wrote this, I am actually a little unclear about exactly how it works so am analyzing now. I think it is designed to only work with stand-alone form, not subform.