Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Access 2007 VBA ISBN: 978-0-470-04684-5
This is the forum to discuss the Wrox book Beginning Access 2007 VBA by Denise M. Gosnell; ISBN: 9780470046845
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Access 2007 VBA ISBN: 978-0-470-04684-5 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 Display Modes
  #1 (permalink)  
Old August 1st, 2008, 11:44 PM
Authorized User
 
Join Date: Nov 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Code Error Chapter 5

In chapter 5 pg. 167, the code reads:
'move to the next record in the local record since the
'current one is being deleted
If Not rsContacts.EOF Then
   rsContacts.MoveNext
  'save the id of the current (next) record
  intCurContact = rsContacts!intContactId
End If

but if you delete the last record in the recordset you get and error:
Runtime Error: 3021
Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record.

Any idea on how to correct this.
Thanks
Reply With Quote
  #2 (permalink)  
Old February 21st, 2009, 05:35 PM
Authorized User
 
Join Date: Jul 2008
Location: Portland, OR, USA.
Posts: 38
Thanks: 1
Thanked 2 Times in 2 Posts
Default

Again, this is an old post but I'll post an answer in hope of helping someone at a later date.

You can easily add an error handler and trap for error 3021 and then just exit the sub or function when you encounter it.
__________________
Thanks,

Bob Larson
Access MVP (2008-2010, 2011)
Free Access tutorials, samples, tools
Reply With Quote
  #3 (permalink)  
Old July 23rd, 2010, 06:20 AM
Registered User
 
Join Date: Jun 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 5 pg 167 - When Delete last record - crash

Quote:
Originally Posted by boblarson View Post
Again, this is an old post but I'll post an answer in hope of helping someone at a later date.

You can easily add an error handler and trap for error 3021 and then just exit the sub or function when you encounter it.
What the solution to add / change codes to prevent it crash - how to do it

If Not rsContacts.EOF Then
rsContacts.MoveNext
'save the id of the current (next)record
intCurContact = rsContacts!PCNumber
End If

error didplay: runtime error 3021 - either BOF or EOF is TRUE or the current has been deleted
Reply With Quote
Reply


Thread Tools
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
Chapter 14 Code Error? pherank BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 July 4th, 2008 10:05 PM
Chapter 12 code error rsteph7 BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 34 August 18th, 2004 02:53 PM
Chapter 6 p.171 Code Error bonehead BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 June 26th, 2004 06:28 PM



All times are GMT -4. The time now is 04:59 PM.


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