473,397 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

How to stop 2105 Message, Can't go to next record (Urgent, please help!)

3
Hey all, this is hopefully so simple you want to laugh me off the forum but it would Really Really help if you could...well help me!

I've got this 'browse' form to allow user to go through records one by one, but when I get to the end of the data two things happen:

First, it goes to a blank page (to make a new record I assume) - This is fine.

One more click after that I get a "2105" Which states "You can't go to specified record". however when it does this its an ugly box with 'end debug help' - This I do not want!

How do I add my own message just saying 'no more records'?

Thank you kindly!

oh btw the code for the button is:

Private Sub btn_Next_Rec_Click()
DoCmd.GoToRecord , , acNext
End Sub
Apr 8 '08 #1
1 3275
nico5038
3,080 Expert 2GB
Hey all, this is hopefully so simple you want to laugh me off the forum but it would Really Really help if you could...well help me!

I've got this 'browse' form to allow user to go through records one by one, but when I get to the end of the data two things happen:

First, it goes to a blank page (to make a new record I assume) - This is fine.

One more click after that I get a "2105" Which states "You can't go to specified record". however when it does this its an ugly box with 'end debug help' - This I do not want!

How do I add my own message just saying 'no more records'?

Thank you kindly!

oh btw the code for the button is:

Private Sub btn_Next_Rec_Click()
DoCmd.GoToRecord , , acNext
End Sub
You can test or the last record (you allow "new") is the new record and skip the action like:
Expand|Select|Wrap|Line Numbers
  1. Private Sub btn_Next_Rec_Click()
  2. If Me.Newrecord then
  3.    ' no action
  4. else
  5.    DoCmd.GoToRecord , , acNext
  6. end if
  7. End Sub
  8.  
Personally I prefer to disable such a [Next] button on forhand by adding to the OnCurrent event of the form. As you'll also want to protect the btnPrevious, you could use code like:
Expand|Select|Wrap|Line Numbers
  1. Private Sub btnFirst_Click()
  2.  
  3.     DoCmd.GoToRecord , , acFirst
  4.     Call subEnable
  5.  
  6. End Sub
  7. Private Sub btnPrev_Click()
  8.  
  9.     DoCmd.GoToRecord , , acPrevious
  10.     Call subEnable
  11.  
  12. End Sub
  13. Private Sub btnLast_Click()
  14.  
  15.     DoCmd.GoToRecord , , acLast
  16.     Call subEnable
  17.  
  18. End Sub
  19. Private Sub btnNext_Click()
  20.  
  21.     DoCmd.GoToRecord , , acNext
  22.     Call subEnable
  23.  
  24. End Sub
  25.  
  26. Sub subEnable()
  27.  
  28.     ' init buttons
  29.     Me.btnFirst.Enabled = True
  30.     Me.btnPrev.Enabled = True
  31.     Me.btnLast.Enabled = True
  32.     Me.btnNext.Enabled = True
  33.  
  34.     ' correct for first and last row reached
  35.     If Me.CurrentRecord = 1 Then
  36.        Me.btnNext.SetFocus
  37.        Me.btnFirst.Enabled = False
  38.        Me.btnPrev.Enabled = False
  39.     End If
  40.  
  41.     If Me.CurrentRecord = Me.Recordset.RecordCount Then
  42.        Me.btnPrev.SetFocus
  43.        Me.btnLast.Enabled = True
  44.        Me.btnNext.Enabled = False
  45.     End If
  46.  
  47.  
  48. End Sub
  49.  
  50. Private Sub btnTagTest_Click()
  51. Dim ctl As Control
  52.  
  53. For Each ctl In Me.Controls
  54.     If ctl.Tag <> "" Then
  55.        Debug.Print ctl.Name, ctl.Tag
  56.     End If
  57. Next
  58. End Sub
  59.  
BTW, the above code doesn't allow new records, check the difference :-)

Getting the idea ?

Nic;o)
Apr 8 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Edwinah63 | last post by:
Hi Everyone, All the very best for 2004!! i need urgent help with this problem, the users are about to skin me alive!! we have an access front end with linked to sql server 2k tables. ...
3
by: William Wisnieski | last post by:
Hello Everyone, Access 2000, I have a main unbound form with a bound datasheet subform . The subform is bound to a query that returns records based on criteria in the main form. The user...
4
by: Tim | last post by:
I have used a graphic 'next record' button on a form. How can I stop it from going past the last existing record? In other words, I don't want it to take the user to a blank record. Thanks Tim
2
by: Adam - Regus | last post by:
Hi, I just created a form with a text box "COFFEE" and another box that I use to calculate the price of the coffee , with each one being $12.50 "COFFEE PRICE". All is good except that each...
2
by: Gerry Abbott | last post by:
Hi all, Ive got a bound form (its actually a subform), but want to ensure that a specific field is populated before the user can move away from that record. Can anyone suggest the best method...
8
by: Kapil Jain | last post by:
Dear All, I have score table in which i am storing scores for online quiz what i want is to allot rank to all candidates as per their scores for that i applied logic that i sorted table order by...
1
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include...
1
matthardwick
by: matthardwick | last post by:
I have a form that has lots of sub forms on it. The user shouldn't be editing the information that isn't part of the sub forms, and the fields are locked... but when a user presses return/enter -...
3
by: Sam Zuhbi | last post by:
Hi, I was wondering how do I make the next record button on my access 2007 form stop at the last record, I want to make sure that if it does not create a new record if it reaches the last record...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.