By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,070 Members | 1,718 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,070 IT Pros & Developers. It's quick & easy.

Custom Navigation Button Woes

P: n/a
I am having some trouble with some old code revolving around custom
form navigation buttons. My main form has a sub-form with these custom
navigation buttons. In other words, the code should be modular and
work across forms and sub-forms. My previous code was taken from the
Access Expert Solutions 97 (Leszynski) many years ago. As my database
became more complex with multiple sub-forms and intricate combo boxes,
the code faltered.

Some excerpts from the code follow. These areas may point to some of
the idiosyncrasies. Error handling has been excludes for this post.
Private Sub btnNext_Click()

Call FrmFocusSave(Screen.PreviousControl)
Call FrmNavGotoNext(Screen.ActiveForm)
Call FrmFocusRestore

End Sub

Public Sub FrmFocusSave(ctl As Control)
' Purpose: Save a pointer to the active control

Set mctlFocusSave = ctl ' Save the pointer
End Sub
Public Sub FrmNavGotoNext(rfrm As Form)
' Purpose: Goto next record in form recordset

If rfrm.mtdValidate Then ' Record is valid
If Not FrmNavIsLast(rfrm) Then
rfrm.SetFocus ' Just to be sure
Application.RunCommand acCmdRecordsGoToNext
End If
End If
End Sub

Screen.ActiveForm seems to have issues when placed behind the
navigation buttons of a sub-form. The Screen.ActiveForm grabs the
main form (not the sub-form). Screen.PreviousControl may have a
similar effect. The screen method does not aid the debugging process
since the debugging window has focus not a form. Maybe, another
approach exist. Please let me know another approach to custom
navigation buttons. In addition, how does acquire the previous
control and active form in a bulletproof manner.

The sub-form may have additional issues, but I save the specifics for
the next post. Just keep in mind that each form may be open by another
form in dialog mode. So I am continually jumping from one form to
another. The custom navigation button should allow for this usage.

Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I have some additional details about my database dilemma.

My original custom navigation buttons perform as expect if you open
the form in normal view. The custom navigation buttons falter when you
open the form on a particular record. In other words, open the Project
form the database window, the navigation buttons work. Open the
Project form and select the Company tab, then press the command
button, which opens the Company form on the selected company record,
the custom navigation button stumble. Maybe, the custom navigation
buttons trip on filtered forms (hmm).

Please let me know if you have any workarounds for this situation.
The code for the command button follows. Does anybody have a better
way for opening forms with a command button? In addition, I could
still use another approach to custom navigation buttons.
Private Sub cmdGoComp_Click()

Dim strDocName As String
Dim strLinkCriteria As String

strDocName = "frmComp"

strLinkCriteria = "[CompID]=" & Me![tblComp.CompID]
DoCmd.OpenForm strDocName, , , strLinkCriteria, acFormEdit,
acWindowNormal

End Sub
On Wed, 04 Feb 2004 11:52:13 -0800, Robert Neville
<robert_neville@y@h0o.com> wrote:
I am having some trouble with some old code revolving around custom
form navigation buttons. My main form has a sub-form with these custom
navigation buttons. In other words, the code should be modular and
work across forms and sub-forms. My previous code was taken from the
Access Expert Solutions 97 (Leszynski) many years ago. As my database
became more complex with multiple sub-forms and intricate combo boxes,
the code faltered.

Some excerpts from the code follow. These areas may point to some of
the idiosyncrasies. Error handling has been excludes for this post.
Private Sub btnNext_Click()

Call FrmFocusSave(Screen.PreviousControl)
Call FrmNavGotoNext(Screen.ActiveForm)
Call FrmFocusRestore

End Sub

Public Sub FrmFocusSave(ctl As Control)
' Purpose: Save a pointer to the active control

Set mctlFocusSave = ctl ' Save the pointer
End Sub
Public Sub FrmNavGotoNext(rfrm As Form)
' Purpose: Goto next record in form recordset

If rfrm.mtdValidate Then ' Record is valid
If Not FrmNavIsLast(rfrm) Then
rfrm.SetFocus ' Just to be sure
Application.RunCommand acCmdRecordsGoToNext
End If
End If
End Sub

Screen.ActiveForm seems to have issues when placed behind the
navigation buttons of a sub-form. The Screen.ActiveForm grabs the
main form (not the sub-form). Screen.PreviousControl may have a
similar effect. The screen method does not aid the debugging process
since the debugging window has focus not a form. Maybe, another
approach exist. Please let me know another approach to custom
navigation buttons. In addition, how does acquire the previous
control and active form in a bulletproof manner.

The sub-form may have additional issues, but I save the specifics for
the next post. Just keep in mind that each form may be open by another
form in dialog mode. So I am continually jumping from one form to
another. The custom navigation button should allow for this usage.


Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.