Navigation AddNew Record woes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • emalcolm_FLA@comcast.net

    Navigation AddNew Record woes

    Hello and TIA for your consideration.

    I have created several db's for a non-profit and they want custom
    navigation buttons to display "You are on the first record, last
    record, etc". With this ng help I've created code for all except the
    add new record command button.

    If I create individual sub functions behind each form, no problem.

    The problem is I am trying to create a re-usable module.

    CBF (works):
    Private Sub cmdNewRec_Click ()
    Dim rs As DAO.Recordset

    Set rs = Me.RecordsetClo ne

    If Me.NewRecord Then
    MsgBox "You are on a blank record", vbOKOnly, "Data Navigation"
    ElseIf Not rs.EOF Then
    DoCmd.GoToRecor d , , acNewRec
    Me.txt_radioNbr .SetFocus
    End If

    Set rs = Nothing

    End Sub

    Function (add new record is stepped into but the cursor stays on
    current record):
    Function NavButtons(strN av As String)
    'Purpose: Re-usable module for navigating the form
    'Called by: Navigation buttons on forms
    'Variables: First, Previous, Next, Last and New
    'Returns: Nothing
    'Created: Terry Wickenden


    Dim frmCurrent As Form
    Dim rsNavigate As DAO.Recordset

    On Error GoTo ErrNavButtons

    Set frmCurrent = Screen.ActiveFo rm
    Set rsNavigate = frmCurrent.Reco rdsetClone

    Select Case strNav
    Case "First"
    If frmCurrent.Curr entRecord = 1 Then
    MsgBox "You are on the first record", vbOKOnly, "Data Navigation"
    Else
    rsNavigate.Move First
    End If
    Case "Prev"
    If frmCurrent.Curr entRecord = 1 Then
    MsgBox "You are on the first record", vbOKOnly, "Data
    Navigation"
    Else
    rsNavigate.Move Previous
    End If
    Case "Next"
    If frmCurrent.NewR ecord Then
    MsgBox "You are on a blank record", vbOKOnly, "Data
    Navigation"

    ElseIf frmCurrent.Curr entRecord =
    frmCurrent.Reco rdsetClone.Reco rdCount Then
    MsgBox "You are on the last record", vbOKOnly, "Data
    Navigation"
    Else
    rsNavigate.Move Next
    End If
    Case "Last"
    If frmCurrent.Curr entRecord =
    frmCurrent.Reco rdsetClone.Reco rdCount Then
    MsgBox "You are on the last record", vbOKOnly, "Data
    Navigation"
    Else
    rsNavigate.Move Last
    End If
    Case "new"
    If frmCurrent.NewR ecord Then
    MsgBox "You are on a blank record", vbOKOnly,
    "Data Navigation"
    Else
    DoCmd.GoToRecor d , , acNewRec
    End If

    End Select
    frmCurrent.Book mark = rsNavigate.Book mark
    Set rsNavigate = Nothing

    ExitNavButtons:
    Exit Function

    ErrNavButtons:
    MsgBox Error$
    Resume ExitNavButtons

    End Function

    Again Thanks for any suggestions.
Working...