Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Access 2003 VBA Programmer's Reference
This is the forum to discuss the Wrox book Access 2003 VBA Programmer's Reference by Patricia Cardoza, Teresa Hennig, Graham Seach, Armen Stein; ISBN: 9780764559037
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Access 2003 VBA Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 10th, 2005, 11:44 AM
Registered User
 
Join Date: Dec 2004
Location: Manchester, NH, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Wizard generated navigation buttons

Hi to all, I have a question about the "Control Wizards" generated record navigation buttons on a form. The form is generated from a table and I don't want to use the default record navigation buttons. I used the "Control Wizards" enable on the tool bar when I make a button so I can make my own buttons to navigate through the records.

My problem is that the buttons that go to the "Next" or "Previous" record gives an error message, "You can't go to the specified record.", when when I go to the EOF or BOF. Here's the code generated by the wizard for the button.

Private Sub cmdNext_Click()
On Error GoTo Err_cmdNext_Click

    DoCmd.GoToRecord , , acNext

Exit_cmdNext_Click:
    Exit Sub

Err_cmdNext_Click:
    MsgBox Err.Description
    Resume Exit_cmdNext_Click

End Sub

What I want to do is check for EOF or BOF and disable the button or if I could tell want the record count is I could keep track of that to not go past EOF or BOF. I'm still looking but I have not found any reference to this in the book.

Any help would be greatly appreciated.
Regards Mike G.

Reply With Quote
  #2 (permalink)  
Old January 10th, 2005, 06:54 PM
Authorized User
 
Join Date: Jul 2004
Location: Sydney, NSW, Australia.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Mike,

The Wizards are reknowned for generating some fairly stodgey code. I'd be inclined to rewrite them:

Private Sub cmdMoveNext_Click()
    Me.cmdMovePrevious.Enabled = True

    If Not Me.NewRecord Then
        DoCmd.GoToRecord , , acNext
        If Me.NewRecord Then
            DoCmd.GoToRecord , , acPrevious

            Me.cmdMovePrevious.SetFocus
            Me.cmdMoveNext.Enabled = False
        End If
    End If
End Sub

Private Sub cmdMovePrevious_Click()
    On Error Resume Next

    Me.cmdMoveNext.Enabled = True

    If Not Me.RecordsetClone.BOF Then
        DoCmd.GoToRecord , , acPrevious

        If Err <> 0 Then
            Me.cmdMoveNext.SetFocus
            Me.cmdMovePrevious.Enabled = False
        End If
    End If
End Sub

In any case, for general questions about Access, refer to the following page for information about logging onto the Microsoft newsgroups, where you can get help 24/7.

http://www.pacificdb.com.au/MVP/newsgroup.htm

Graham R Seach
Microsoft Access MVP
Reply With Quote
  #3 (permalink)  
Old January 11th, 2005, 01:26 AM
Registered User
 
Join Date: Dec 2004
Location: Manchester, NH, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear Graham, thank you very much for your quick reply, the info is exactly what I was looking for.

Thanks again, Mike G.

Reply With Quote
  #4 (permalink)  
Old January 11th, 2005, 02:33 AM
Authorized User
 
Join Date: Jul 2004
Location: Sydney, NSW, Australia.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Mike,

I just realised - in cmdMovePrevious_Click(), you can omit the "If Not Me.RecordsetClone.BOF Then" line (and its associated "End If", because they're redundant.



Graham R Seach
Microsoft Access MVP
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Navigation Wizard Control everest ASP.NET 2.0 Professional 0 January 17th, 2007 06:22 PM
intelligent navigation buttons NeoCat Access 13 September 17th, 2005 07:43 PM
Navigation buttons terry s Dreamweaver (all versions) 3 August 3rd, 2004 04:03 PM
Intelligent Navigation Buttons twsinc Access VBA 1 October 7th, 2003 09:07 AM
Animated Buttons Inside Navigation Bars? Ben Horne Dreamweaver (all versions) 0 October 5th, 2003 09:59 PM



All times are GMT -4. The time now is 08:30 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.