473,748 Members | 2,594 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 3624
"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
4017
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
4157
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
3042
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
2364
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
2130
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
13289
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
2315
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
3809
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
3253
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
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9386
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
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
9254
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
8255
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...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3319
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
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.