Results 1 to 3 of 3
  1. #1
    iProRyan is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2011
    Location
    England, United Kingdom
    Posts
    44

    Record information in a label and disabling buttons by code.

    Hi Guys,

    How would I go about some VBA code to say "Record X of Y" I know I can do this by showing the Record Selectors in Access but I do not want to, also is it possible to disable my next button when it gets to Record X of X (5 of 5 - they're the same) and the same for previous button?

    Thanks,


    Ryan

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    You want your Previous button disabled when you reach X of X?

    You could try putting this:
    = Count([Primary_Key_Field])
    in the Record Sorce Property of the Text Box.
    That would give you the Max number of records in the Form's recordset . .

    Here's a site that tackles this:
    http://www.tek-tips.com/viewthread.cfm?qid=1280490

    Hope this helps!

  3. #3
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I modified the code from "TheAccess Web" at http://access.mvps.org/access/forms/frm0026.htm

    Code:
    Private Sub Form_Current()
       If Me.NewRecord Then
          Me!lblNavigate.Caption = "New Record"
       Else
          With Me.RecordsetClone
             .Bookmark = Me.Bookmark
             Me!lblNavigate.Caption = "Record " & .AbsolutePosition + 1 & " of " & .RecordCount
    
             'disable next button if at last record
             Me.btnNext.Enabled = ((.AbsolutePosition + 1) <> .RecordCount)
             
             'disable previous button if at first record
             Me.btnPrev.Enabled = ((.AbsolutePosition + 1) <> 1)
    
          End With
    
       End If
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Command buttons and Code
    By Jillette in forum Forms
    Replies: 4
    Last Post: 04-25-2012, 05:06 PM
  2. Code issue on Format of label
    By Gavroche in forum Reports
    Replies: 2
    Last Post: 09-14-2011, 06:19 AM
  3. VBA Code for buttons, Access 2010
    By nchesebro in forum Programming
    Replies: 3
    Last Post: 06-29-2011, 09:21 AM
  4. Navigation Buttons Stop My Code
    By millerdav99 in forum Programming
    Replies: 6
    Last Post: 03-18-2011, 11:13 AM
  5. Replies: 1
    Last Post: 03-24-2010, 02:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums