Kamis, 20 Maret 2014

[MS_AccessPros] Navigation Buttons

 


Good morning

It's been a while since Bill Mosca last helped me with the Navigation buttons problem. The code that I got from Bill has solved my trouble. 

Recently I added a new form to my application, and I removed the "cmdGoNew" button from the form since this form doesn't need to add new records. However it generates an Error 2465 (Apllication-defined or object-defined error), I got around the trouble by putting it back and made the button invisible. This temporary solved the problem. However this might not be the appropriate way. How do I modify the code to make the button is an optional?

Since I don't remember the post # and won't be able to reply to Bill directly, I paste the code here which I got from Bill.

Thank you

Phucon

Message 2 of 2 , Today at10:17 AM

'Purpose  : EnableDisable nav buttons.

'Form's current event:

Private Sub Form_Current()

    Call CheckPosition(Me)

    Me.lblRecCt.Caption = Me.CurrentRecord & " of " & Me.Recordset.RecordCount

End Sub

'Public routine called by all forms as needed. Occasionally, I need to pass

'an array of controls to re0query, but not very often.

Public Sub CheckPosition(frm As Form, ParamArray ctrls())

'Purpose  : Enable/disable nav buttons.

'           txtFocus is a textbox that is used only to get

'           Focus during enabling/disabling. It is just a

'           dot on the form placed near nav buttons.

'DateTime : 11/29/2006 07:50

'Author   : Bill Mosca

    Dim lngRecNum As Long

    Dim lngRecCt As Long

    Dim x As Integer

     lngRecNum = frm.CurrentRecord

     '    frm.RecordsetClone.MoveFirst

    If lngRecNum < frm.Recordset.RecordCount Then

        frm.RecordsetClone.MoveLast

    End If

     lngRecCt = frm.RecordsetClone.RecordCount

    frm.txtFocus.SetFocus

    frm.cmdGoFirst.Enabled = lngRecNum <> 1

    frm.cmdGoPrev.Enabled = lngRecNum <> 1

    frm.cmdGoNext.Enabled = lngRecNum < lngRecCt

    frm.cmdGoLast.Enabled = lngRecNum < lngRecCt

    frm.cmdGoNew.Enabled = frm.Recordset.RecordCount <> 0

     'No Additions should disable "New" button

    If frm.AllowAdditions = False Then

        frm.cmdGoNew.Enabled = False

    Else

        frm.cmdGoNew.Enabled = frm.Recordset.RecordCount <> 0

    End If

     'If any cbo's or lst's have a user-defined function for RowSourceType

    'they will need to be requeried.

    If Not IsNull(ctrls) Then

        For x = 0 To UBound(ctrls)

            If ctrls(x).ControlSource = "" Then ctrls(x) = Null

            ctrls(x).Requery

        Next

    End If

End Sub

 

 

 

 

 

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)
.

__,_._,___

Tidak ada komentar:

Posting Komentar