Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Developer Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Nav Buttons
Ivan Dammash 
    
2 years ago
G'Day my name is Ivan and I live a Mullett Creek Queensland AU.
On the application I am building I have 12 + Standard forms, Model forms and sub forms that have buttons for First, Previous, Next, Last and new record. I have written a procedure to enable or disable nav buttons depending if the record pointer is on the first or last record, (the sub works fine).
Rather then adding this sub to all the forms with nav buttons.
I would like to have it, the sub in a public module and call it where needed. How to tell it which form is calling it, is  where my 84 year brain bogs down. Any suggestions would be appreciated. Included is the navigation enable disable code.

Details
Sub NavBtns()
    On Error Resume Next
        If Me.CurrentRecord = 1 Then
            Me.btnGoToPrevious.Enabled = False'Previous Nav Button
            Me.btnGoToFirst.Enabled = False'First Nav Button
        Else
            Me.btnGoToPrevious.Enabled = True
            Me.btnGoToFirst.Enabled = True
        End If
    '-------------------------------------------
    If Me.CurrentRecord = Me.Recordset.RecordCount Then
        Me.btnGoToLast.Enabled = False'Last Nav Button
    Else
        Me.btnGoToLast.Enabled = True
    End If
    '---------------------------------------------
    If Me.CurrentRecord >= Me.Recordset.RecordCount Then
        Me.btnGoToNext.Enabled = False'Next Nav Button
    Else
        Me.btnGoToNext.Enabled = True
    End If
    '-------------------------------------------
    If Me.NewRecord Then
        Me.btnNew.Enabled = False'New Record Button
    Else
        Me.btnNew.Enabled = True
    End If
End Sub


Cheers and Have a Great New Year.
Sami Shamma  @Reply  
             
2 years ago
G'day Iven
I have not tested this, but give it a try:
1) make the Sub Public
2) send it as a parameter the form name that is calling it (I believe it is Me.Name)
3) replace "Me" part of Me.ControlName with the parameter you sent.

something along the following lines:

From the calling form :
  NavBtns Me.name

In the Global Mod

Public NavBtns (FormName as String)
now use the FormName inside your Sub.

As I said, I have not tested this; however, I hope it will get you started.

BTW I visited Brisbane & the Gold Cost few years back.
Kevin Robertson  @Reply  
          
2 years ago
The correct syntax would be Forms(FormName)!YourControlName.Enabled = True
Kevin Yip  @Reply  
     
2 years ago
Hi Ivan, Me.Recordset.RecordCount may not always give you the actual record count, so that may affect how your code works.   RecordCount is only able to return the actual count when the last record of the recordset is accessed.  When you first open a form, Access may not retrieve all the records (if there are a large number of them), so the actual record count is unknown to Access at that point.  If your form has only a few records, you may get by.  But as your database grows, so does the record count of your tables; so this is something to keep in mind about.  In online remote database access, Recordcount always never gives you the exact count because it would slow down performance to access all records.  The RecordCount property is only really good for checking whether there is any record or not.  If there is, it will return at least 1; if not, it will return zero.  

In my old job, I used the .BOF and .EOF properties to check whether the first or last record is reached.
Ivan Dammash OP  @Reply  
    
2 years ago
Thank you for your suggestions, I have been away and have not been able to try your suggestions.
Again Thank you and do have a Happy New year.
Regards Ivan D.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/6/2026 12:37:18 PM. PLT: 2s