473,396 Members | 2,024 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,396 software developers and data experts.

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.RecordsetClone.Bookmark = Me.Bookmark
Me!lblCount.Caption = Me.RecordsetClone.AbsolutePosition + 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 3607
"Robert" <pr**********@yahoo.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.RecordsetClone.Bookmark = Me.Bookmark
Me!lblCount.Caption = Me.RecordsetClone.AbsolutePosition + 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.RecordsetClone.Bookmark = Me.Bookmark
Me!lblCount.Caption = Me.RecordsetClone.AbsolutePosition + 1

Err_Gest:
If Err.Number=3021 then
If me.NewRecord then
Me!lblCount.Caption=Me.RecordsetClone.RecordCount+ 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.Caption = Me.CurrentRecord

shoule be sufficient or you could use

If Not Me.NewRecord Then
Me!lblCount.Caption = Me.CurrentRecord
Else
Me!lblCount.Caption = ""
End If

Robert

"Alessandro Baraldi" <ik****@libero.it> wrote in message
news:28***********************************@mygate. mailgate.org...
"Robert" <pr**********@yahoo.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.RecordsetClone.Bookmark = Me.Bookmark
Me!lblCount.Caption = Me.RecordsetClone.AbsolutePosition + 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.RecordsetClone.Bookmark = Me.Bookmark
Me!lblCount.Caption = Me.RecordsetClone.AbsolutePosition + 1

Err_Gest:
If Err.Number=3021 then
If me.NewRecord then
Me!lblCount.Caption=Me.RecordsetClone.RecordCount+ 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
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...
3
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...
0
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
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...
0
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...
4
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
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...
1
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. ...
15
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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
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...
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.