Seems to me that nobody but novices uses DoCmd.GoToRecord for plain
old record navigation, whether in parent forms or child forms.
I guess that would explain why I was trying to use it.
Thanks for the tips fellas. I ended up recreating my code without using
DoCmd.GoToRecord. Seems to work much better this way. One other
question: Recordset versus RecordsetClone with Bookmarks? I used
Recordset here so that my forms update without a requery when I add or
delete a record. Is this the correct method?
Thanks again.
I've posted my global navigation code below:
Function fcnNavigation(frmForm As Form, Optional strFunction As String,
_
Optional strFindString As String)
Dim rs As Object
Set rs = frmForm.Recordset
Select Case strFunction
Case "Open"
rs.MoveLast
rs.MoveFirst
frmForm.cmbQuickFind.RowSource = frmForm.RecordSource
Case "First"
rs.MoveFirst
Case "Next"
rs.MoveNext
Case "Prev"
rs.MovePrevious
Case "Last"
rs.MoveLast
Case "New"
rs.AddNew
rs.Update
frmForm.cmbQuickFind.RowSource = frmForm.RecordSource
Case "Delete"
rs.Delete
rs.MoveFirst
frmForm.cmbQuickFind.RowSource = frmForm.RecordSource
Case "QuickFind"
rs.FindFirst strFindString
Case Else
frmForm.cmbQuickFind.RowSource = frmForm.RecordSource
End Select
Select Case rs.RecordCount
Case Is < 2 'either a new record, or one loaded
frmForm.cmdFirstRecord.Enabled = False
frmForm.cmdPreviousRecord.Enabled = False
frmForm.cmdNextRecord.Enabled = False
frmForm.cmdLastRecord.Enabled = False
frmForm.cmbQuickFind.Enabled = False
Case Else 'more than 1 loaded
If frmForm.cmbQuickFind.Enabled = False Then
frmForm.cmbQuickFind.Enabled = True
End If
If frmForm.CurrentRecord = rs.RecordCount Then 'sittin on the last
record
frmForm.cmdFirstRecord.Enabled = True
frmForm.cmdPreviousRecord.Enabled = True
frmForm.cmdPreviousRecord.SetFocus
frmForm.cmdNextRecord.Enabled = False
frmForm.cmdLastRecord.Enabled = False
End If
If frmForm.CurrentRecord < rs.RecordCount Then 'not on last record
frmForm.cmdNextRecord.Enabled = True
frmForm.cmdLastRecord.Enabled = True
If frmForm.CurrentRecord <1 Then 'not on first record
frmForm.cmdFirstRecord.Enabled = True
frmForm.cmdPreviousRecord.Enabled = True
Else 'sittin on the first record
frmForm.cmdNextRecord.SetFocus
frmForm.cmdFirstRecord.Enabled = False
frmForm.cmdPreviousRecord.Enabled = False
End If
End If
End Select
frmForm.lblNavInfo.Caption = frmForm.CurrentRecord & " of " &
rs.RecordCount
Set rs = Nothing
End Function