Custom Navigation Button Woes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robert Neville

    Custom Navigation Button Woes

    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(Sc reen.PreviousCo ntrol)
    Call FrmNavGotoNext( Screen.ActiveFo rm)
    Call FrmFocusRestore

    End Sub

    Public Sub FrmFocusSave(ct l 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.mtdValidat e Then ' Record is valid
    If Not FrmNavIsLast(rf rm) Then
    rfrm.SetFocus ' Just to be sure
    Application.Run Command acCmdRecordsGoT oNext
    End If
    End If
    End Sub

    Screen.ActiveFo rm seems to have issues when placed behind the
    navigation buttons of a sub-form. The Screen.ActiveFo rm grabs the
    main form (not the sub-form). Screen.Previous Control 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.

  • Robert Neville

    #2
    Re: Custom Navigation Button Woes

    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:
    [color=blue]
    >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(Sc reen.PreviousCo ntrol)
    > Call FrmNavGotoNext( Screen.ActiveFo rm)
    > Call FrmFocusRestore
    >
    >End Sub
    >
    >Public Sub FrmFocusSave(ct l 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.mtdValidat e Then ' Record is valid
    > If Not FrmNavIsLast(rf rm) Then
    > rfrm.SetFocus ' Just to be sure
    > Application.Run Command acCmdRecordsGoT oNext
    > End If
    > End If
    > End Sub
    >
    >Screen.ActiveF orm seems to have issues when placed behind the
    >navigation buttons of a sub-form. The Screen.ActiveFo rm grabs the
    >main form (not the sub-form). Screen.Previous Control 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.[/color]

    Comment

    Working...