how to identify if last record?

  • Thread starter krzysztof via AccessMonster.com
  • Start date
K

krzysztof via AccessMonster.com

Good Day!

i need a little help. i want to identify that the record that i am viewing
on my form is the last record. i maybe not had enough joe this morning, but
i cannot get this. any thoughts? any help is much appreciated.

~K
 
J

Jeff Boyce

Define "last".

Now ask yourself, "does Access have the same definition that I do?"
Probably not!

Access tables are "buckets o' data", with no particular order to them.
"Last" implies something that's being used to order the records. What are
you using?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
D

David PONDA

use...

Dim Dummy as String
Dim db As Database
Dim Enr As Recordset
Set db = CurrentDb
Set Enr = db.OpenRecordset("YourTable", dbOpenDynaset)

Enr.MoveLast
Dummy = Enr!AnyFeld (here any field you want in your table as the last
record)
 
K

krzysztof via AccessMonster.com

Jeff,
Thanks for your reply. Usually in access, when you are click through
the records in a form and you reach the last one, you get a message "Cannot
go to the specified record'. the button is attached to the 'acNext' command.
There is no 'next' field for Access to go to, hence the error. You are right,
Access does have a different definition than I do! How can I identify that
there is not a 'Next' field available, so I do not prompt this error message?
My table is contsant - with only daily updates inported from another system.
This was the way it was specified to be designed. Any help is much
appreciated.

another note: How does one achieve this title of 'MS Access MVP'?

Jeff said:
Define "last".

Now ask yourself, "does Access have the same definition that I do?"
Probably not!

Access tables are "buckets o' data", with no particular order to them.
"Last" implies something that's being used to order the records. What are
you using?

Regards

Jeff Boyce
Microsoft Office/Access MVP
Good Day!
[quoted text clipped - 5 lines]
 
J

Jeff Boyce

I'm a bit confused between "field" and "record" in your description.

Once again, though, the "last" record depends on how your records are
sorted.

Let's take a different appraoch -- why? What is it that you want to do with
knowledge about the "last" record?

If, as you mentioned, you don't want a "no next record" error message, you
could add error handling to your code behind the form and bypass (or offer
an alternative to) the error message.

The folks at Microsoft note support (user groups, publications, newsgroup
responses, etc.). Check the MVP website:


Regards

Jeff Boyce
Microsoft Office/Access MVP


krzysztof via AccessMonster.com said:
Jeff,
Thanks for your reply. Usually in access, when you are click through
the records in a form and you reach the last one, you get a message
"Cannot
go to the specified record'. the button is attached to the 'acNext'
command.
There is no 'next' field for Access to go to, hence the error. You are
right,
Access does have a different definition than I do! How can I identify
that
there is not a 'Next' field available, so I do not prompt this error
message?
My table is contsant - with only daily updates inported from another
system.
This was the way it was specified to be designed. Any help is much
appreciated.

another note: How does one achieve this title of 'MS Access MVP'?

Jeff said:
Define "last".

Now ask yourself, "does Access have the same definition that I do?"
Probably not!

Access tables are "buckets o' data", with no particular order to them.
"Last" implies something that's being used to order the records. What are
you using?

Regards

Jeff Boyce
Microsoft Office/Access MVP
Good Day!
[quoted text clipped - 5 lines]
 
D

David PONDA

Ahhh ok in that case, the better way is to catch the Err.Number and test it,
if there is that one about the last number, juste Resume Next or let display
another message more than the standard one.
ok in code you mean to :

Private Sub Commande0_Click()
On Error GoTo Err_Commande0_Click


DoCmd.GoToRecord , , acNext

Exit_Commande0_Click:
Exit Sub

Err_Commande0_Click:
If Err.Number = 2499 Then '**** Where 2499 is the number
contains error (no more record....) ****
Resume Exit_Commande0_Click
Exit Sub
Else
MsgBox Err.Description
End If

krzysztof via AccessMonster.com said:
Jeff,
Thanks for your reply. Usually in access, when you are click through
the records in a form and you reach the last one, you get a message
"Cannot
go to the specified record'. the button is attached to the 'acNext'
command.
There is no 'next' field for Access to go to, hence the error. You are
right,
Access does have a different definition than I do! How can I identify
that
there is not a 'Next' field available, so I do not prompt this error
message?
My table is contsant - with only daily updates inported from another
system.
This was the way it was specified to be designed. Any help is much
appreciated.

another note: How does one achieve this title of 'MS Access MVP'?

Jeff said:
Define "last".

Now ask yourself, "does Access have the same definition that I do?"
Probably not!

Access tables are "buckets o' data", with no particular order to them.
"Last" implies something that's being used to order the records. What are
you using?

Regards

Jeff Boyce
Microsoft Office/Access MVP
Good Day!
[quoted text clipped - 5 lines]
 
Top