subform navigation from subsubform

AlanS

Registered User.
Local time
Yesterday, 20:54
Joined
Mar 23, 2001
Messages
292
At management's direction, I've designed a navigation bar to replace the one Access displays when a form's Navigation Buttons property is set to Yes. It has five command buttons and a label to show the current and total records. It's designed to be used as a subform, and its crucial code appears below.

Form PropertySubForm shows the property items distributed to employees; it is designed to be a subform of Form Employees, but functions on its own as well. I've inserted the navigation bar into both forms. It works in all cases in Form Employees, and also works in Form PropertySubForm when that form is opened on its own. However, with PropertySubForm inserted as a subform of Employees, the PropertySubForm navigation bar always produces a 2105 error (which Microsoft says is by design). Several posters have suggested using GoToControl or SetFocus to change the focus to PropertySubForm before using GoToRecord to navigate it, but neither of those methods will work when called from the procedures in the navigation bar (which is a subform of a subform).

Does anyone know of a way to make this work?

Private Sub DoIt(NavAction As Integer)
'performs record navigation appropriate to the button clicked, and updates record counter
On Error GoTo DoIt_Err
With Me.Parent
DoCmd.GoToRecord acDataForm, .Name, NavAction
UpdateCounter .CurrentRecord, Maxx(.RecordsetClone.RecordCount, .CurrentRecord)
End With
DoIt_Exit:
Exit Sub
DoIt_Err:
'beep if error # 2105 ("You can't go to the specified record."), otherwise display message
If Err.Number = 2105 Then
Beep
Else
MsgBox "Error # " & Err.Number & vbCrLf & Err.Description
End If
GoTo DoIt_Exit
End Sub

Private Sub cmdAddNew_Click()
DoIt acNewRec
End Sub

Private Sub cmdFirst_Click()
DoIt acFirst
End Sub

Private Sub cmdLast_Click()
DoIt acLast
End Sub

Private Sub cmdNext_Click()
DoIt acNext
End Sub

Private Sub cmdPrev_Click()
DoIt acPrevious
End Sub
 

Users who are viewing this thread

Back
Top Bottom