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
1 3275
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: -
Private Sub btn_Next_Rec_Click()
-
If Me.Newrecord then
-
' no action
-
else
-
DoCmd.GoToRecord , , acNext
-
end if
-
End Sub
-
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: -
Private Sub btnFirst_Click()
-
-
DoCmd.GoToRecord , , acFirst
-
Call subEnable
-
-
End Sub
-
Private Sub btnPrev_Click()
-
-
DoCmd.GoToRecord , , acPrevious
-
Call subEnable
-
-
End Sub
-
Private Sub btnLast_Click()
-
-
DoCmd.GoToRecord , , acLast
-
Call subEnable
-
-
End Sub
-
Private Sub btnNext_Click()
-
-
DoCmd.GoToRecord , , acNext
-
Call subEnable
-
-
End Sub
-
-
Sub subEnable()
-
-
' init buttons
-
Me.btnFirst.Enabled = True
-
Me.btnPrev.Enabled = True
-
Me.btnLast.Enabled = True
-
Me.btnNext.Enabled = True
-
-
' correct for first and last row reached
-
If Me.CurrentRecord = 1 Then
-
Me.btnNext.SetFocus
-
Me.btnFirst.Enabled = False
-
Me.btnPrev.Enabled = False
-
End If
-
-
If Me.CurrentRecord = Me.Recordset.RecordCount Then
-
Me.btnPrev.SetFocus
-
Me.btnLast.Enabled = True
-
Me.btnNext.Enabled = False
-
End If
-
-
-
End Sub
-
-
Private Sub btnTagTest_Click()
-
Dim ctl As Control
-
-
For Each ctl In Me.Controls
-
If ctl.Tag <> "" Then
-
Debug.Print ctl.Name, ctl.Tag
-
End If
-
Next
-
End Sub
-
BTW, the above code doesn't allow new records, check the difference :-)
Getting the idea ?
Nic;o)
Sign in to post your reply or Sign up for a free account.
Similar topics
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.
...
|
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...
|
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
|
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...
|
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...
|
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...
|
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...
|
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 -...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
|
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...
|
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...
|
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,...
|
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...
| | |