473,881 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error at last record in form while displaying count

I have a label on my form lblCount and the following code in my form for
displaying a record count:

Private Sub Form_Current()
Me.RecordsetClo ne.Bookmark = Me.Bookmark
Me!lblCount.Cap tion = Me.RecordsetClo ne.AbsolutePosi tion + 1
End Sub

It works fine until I page to the last record and I get:

Run-time Error 3021, No Current Record

How to fix?

Robert
Nov 13 '05 #1
2 3631
"Robert" <pr**********@y ahoo.com> wrote in message
news:3Q******** **********@fe02 .lga
I have a label on my form lblCount and the following code in my form for
displaying a record count:

Private Sub Form_Current()
Me.RecordsetClo ne.Bookmark = Me.Bookmark
Me!lblCount.Cap tion = Me.RecordsetClo ne.AbsolutePosi tion + 1
End Sub

It works fine until I page to the last record and I get:

Run-time Error 3021, No Current Record

How to fix?

Robert

It work fine until you don't click NewRecord when you are at
last or Previous when you are at first...!!!

You lose Error gestion...?

First you know that when you go to next when you
are at last the Absolute position give error, but
the label need to show some value.
This value is the RecordCount+1, but only if you
are on NewRecord, in the other case, if err.Number=3021
you need Resume Next.

Try with this, i write it without test, so good work.

Private Sub Form_Current()
On Error Goto Err_Get

Me.RecordsetClo ne.Bookmark = Me.Bookmark
Me!lblCount.Cap tion = Me.RecordsetClo ne.AbsolutePosi tion + 1

Err_Gest:
If Err.Number=3021 then
If me.NewRecord then
Me!lblCount.Cap tion=Me.Records etClone.RecordC ount+1
Else
Resume Next
End if
Else
msgbox Err.Number & " " & err.Description
End if
Exit sub

@Alex
--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
Nov 13 '05 #2
Thanks for your help. I think I found a much simpler solution. In the case
where there is no need for a record total

Me!lblCount.Cap tion = Me.CurrentRecor d

shoule be sufficient or you could use

If Not Me.NewRecord Then
Me!lblCount.Cap tion = Me.CurrentRecor d
Else
Me!lblCount.Cap tion = ""
End If

Robert

"Alessandro Baraldi" <ik****@libero. it> wrote in message
news:28******** *************** ************@my gate.mailgate.o rg...
"Robert" <pr**********@y ahoo.com> wrote in message
news:3Q******** **********@fe02 .lga
I have a label on my form lblCount and the following code in my form for
displaying a record count:

Private Sub Form_Current()
Me.RecordsetClo ne.Bookmark = Me.Bookmark
Me!lblCount.Cap tion = Me.RecordsetClo ne.AbsolutePosi tion + 1
End Sub

It works fine until I page to the last record and I get:

Run-time Error 3021, No Current Record

How to fix?

Robert

It work fine until you don't click NewRecord when you are at
last or Previous when you are at first...!!!

You lose Error gestion...?

First you know that when you go to next when you
are at last the Absolute position give error, but
the label need to show some value.
This value is the RecordCount+1, but only if you
are on NewRecord, in the other case, if err.Number=3021
you need Resume Next.

Try with this, i write it without test, so good work.

Private Sub Form_Current()
On Error Goto Err_Get

Me.RecordsetClo ne.Bookmark = Me.Bookmark
Me!lblCount.Cap tion = Me.RecordsetClo ne.AbsolutePosi tion + 1

Err_Gest:
If Err.Number=3021 then
If me.NewRecord then
Me!lblCount.Cap tion=Me.Records etClone.RecordC ount+1
Else
Resume Next
End if
Else
msgbox Err.Number & " " & err.Description
End if
Exit sub

@Alex
--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4021
by: muser | last post by:
Can anyone run this program through their compiler or if they can see a logical error please point it out. I have my tutor working on it at the moment but I would rather a less ambigious response than the one I think he will provide. The test data, A:\\"514650.txt", appears at the end of the program. The problem is that the program won't read this file and the debugger as far as i know how to work it won't point out the mistake of any....
3
4161
by: Victor | last post by:
I'm trying to run this java program, but somehow the program always quit w/o giving any error msg at all. it happenned inside the first case statements. Strangely, after printing happen2, it just stopped, and I had no idea what happens. another error is on the last function. I have already declared plane as M x N array, but it keeps giving error like hwone.cpp(50) : warning C4101: 'plane' : unreferenced local variable hwone.cpp(212) :...
0
3051
by: Morten Gulbrandsen | last post by:
mysql> USE company; Database changed mysql> mysql> DROP TABLE IF EXISTS EMPLOYEE; -------------- DROP TABLE IF EXISTS EMPLOYEE -------------- Query OK, 0 rows affected (0.00 sec)
1
2367
by: feck | last post by:
I have a database with several tables, one of which is I use this to bring up a form so you can unlock the record (set by using a yes no box on the data input form to prevent unauthorised tweaking once the record is completed). I would like to move to the last record but 10 to give the form 10 lines of the last entries, rather than one that is achieved by using goto record.... acLast
0
2134
by: Roman | last post by:
I'm trying to create the form which would allow data entry to the Client table, as well as modification and deletion of existing data rows. For some reason the DataGrid part of functionality stops working when I include data entry fields to the form: I click on Delete or Edit inside of DataGrid and get this error: "Error: Object doesn't support this property or method" If I remove data entry fields from the form - DataGrid allows to...
4
13298
by: Rico | last post by:
Hi All, Just wondering, in vb code, how to if the last record on a cascading form is the current record? Thanks!
2
2328
by: jthep | last post by:
I'm trying to get this piece of code I converted from C to work in C++ but I'm getting an access violation error. Problem occurs at line 61. Someone can help me with this? The function display(llist mylist) displays a list of choices for a record book: void display(llist mylist) { char name, address, telno, input; int yearofbirth, choice, records; yearofbirth = 0;
1
3818
by: morrisqueto | last post by:
Hello, One of my websites just started sending a new rare error. The site has been working for almost 2 years without trouble, but today morning started giving away this error in all my views. Microsoft VBScript runtime error '800a01fb' An exception occurred: 'MoveNext' /test.asp, line 544 Here is the code:
15
3267
by: Lawrence Krubner | last post by:
Does anything about this script look expensive, in terms of resources or execution time? This script dies after processing about 20 or 25 numbers, yet it leaves no errors in the error logs. This is on a server that handles a fairly demanding site. The defaults, in php.ini, have all been cranked fairly high: scripts get 180 seconds to run, and they can have as much as 256 megs of RAM. The input for this script is coming from a textarea in...
0
11096
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10812
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10400
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9552
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7953
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7108
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4597
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.