Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Microsoft Access > Navigation AddN...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 30641 of 31576
Post > Topic >>

Navigation AddNew Record woes

by emalcolm_FLA@[EMAIL PROTECTED] Jul 2, 2008 at 04:05 PM

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.RecordsetClone

If Me.NewRecord Then
    MsgBox "You are on a blank record", vbOKOnly, "Data Navigation"
        ElseIf Not rs.EOF Then
    DoCmd.GoToRecord , , 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(strNav 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.ActiveForm
Set rsNavigate = frmCurrent.RecordsetClone

Select Case strNav
    Case "First"
    If frmCurrent.CurrentRecord = 1 Then
    MsgBox "You are on the first record", vbOKOnly, "Data Navigation"
    Else
    rsNavigate.MoveFirst
    End If
        Case "Prev"
        If frmCurrent.CurrentRecord = 1 Then
        MsgBox "You are on the first record", vbOKOnly, "Data
Navigation"
        Else
        rsNavigate.MovePrevious
        End If
            Case "Next"
            If frmCurrent.NewRecord Then
            MsgBox "You are on a blank record", vbOKOnly, "Data
Navigation"

            ElseIf frmCurrent.CurrentRecord =
frmCurrent.RecordsetClone.RecordCount Then
            MsgBox "You are on the last record", vbOKOnly, "Data
Navigation"
            Else
            rsNavigate.MoveNext
            End If
                Case "Last"
                If frmCurrent.CurrentRecord =
frmCurrent.RecordsetClone.RecordCount Then
                MsgBox "You are on the last record", vbOKOnly, "Data
Navigation"
                Else
                rsNavigate.MoveLast
                End If
                    Case "new"
                    If frmCurrent.NewRecord Then
                    MsgBox "You are on a blank record", vbOKOnly,
"Data Navigation"
                    Else
                    DoCmd.GoToRecord , , acNewRec
                    End If

End Select
frmCurrent.Bookmark = rsNavigate.Bookmark
Set rsNavigate = Nothing

ExitNavButtons:
    Exit Function

ErrNavButtons:
    MsgBox Error$
    Resume ExitNavButtons

End Function

Again Thanks for any suggestions.
 




 1 Posts in Topic:
Navigation AddNew Record woes
emalcolm_FLA@[EMAIL PROTE  2008-07-02 16:05:19 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Dec 2 23:18:36 CST 2008.