Display current record number on a subform

A

Access Joe

Hi all,

I have a surgical subform and I would like it to display the current
selected record number. For instance, if a selected patient had three
surgeries, I would like the subform to display something like this: "Record 1
of 3"...."Record 2 of 3", etc.

I've figured out how to display the total count of records [=count(*)], but
I can't figure out how to display the current record number being viewed.
Any ideas?

Thanks everyone!
Joe
 
M

Michel Walsh

Hi,


The AbsolutePosition property of the recordset supplies that information.
Get the clone, synchronize the bookmark, read the position:


With Me.RecordsetClone
.Bookmark = Me.Bookmark ' note the starting dot
RecordNumber = .AbsolutePosition ' again, don't miss the dot
End With




Hoping it may help,
Vanderghast, Access MVP
 
A

Access Joe

Thanks Michel,

One question: I'm not really 'code savvy'. Where exactly would I paste that
code you providede? I'm assuming I would create an unbound control and place
it somewhere there.

Thanks again. I'm looking forward to seeing if it'll work.

Joe
Michel Walsh said:
Hi,


The AbsolutePosition property of the recordset supplies that information.
Get the clone, synchronize the bookmark, read the position:


With Me.RecordsetClone
.Bookmark = Me.Bookmark ' note the starting dot
RecordNumber = .AbsolutePosition ' again, don't miss the dot
End With




Hoping it may help,
Vanderghast, Access MVP


Access Joe said:
Hi all,

I have a surgical subform and I would like it to display the current
selected record number. For instance, if a selected patient had three
surgeries, I would like the subform to display something like this:
"Record 1
of 3"...."Record 2 of 3", etc.

I've figured out how to display the total count of records [=count(*)],
but
I can't figure out how to display the current record number being viewed.
Any ideas?

Thanks everyone!
Joe
 
M

Michel Walsh

Hi,


Indeed, I would place it in the onCurrent event subroutine handler.
=================================
Private Sub Form_Current()

If Me.NewRecord then
Me.RecordNumber = null
Else
Me.RecordsetClone.Bookmark = Me.Bookmark
Me.RecordNumber = 1+ Me.RecordsetClone.AbsolutePosition
End if

End Sub
==================================


Note I added 1, since the absolute position starts at 0


Hoping it may help,
Vanderghast, Access MVP


Access Joe said:
Thanks Michel,

One question: I'm not really 'code savvy'. Where exactly would I paste
that
code you providede? I'm assuming I would create an unbound control and
place
it somewhere there.

Thanks again. I'm looking forward to seeing if it'll work.

Joe
Michel Walsh said:
Hi,


The AbsolutePosition property of the recordset supplies that information.
Get the clone, synchronize the bookmark, read the position:


With Me.RecordsetClone
.Bookmark = Me.Bookmark ' note the starting dot
RecordNumber = .AbsolutePosition ' again, don't miss the dot
End With




Hoping it may help,
Vanderghast, Access MVP


Access Joe said:
Hi all,

I have a surgical subform and I would like it to display the current
selected record number. For instance, if a selected patient had three
surgeries, I would like the subform to display something like this:
"Record 1
of 3"...."Record 2 of 3", etc.

I've figured out how to display the total count of records [=count(*)],
but
I can't figure out how to display the current record number being
viewed.
Any ideas?

Thanks everyone!
Joe
 
W

walkbet

Thank you for posting this code, Michel. And also to Joe for asking
this question. It has been very helpful to me.

Betsy
 
A

Access Joe

Thanks Michel. I'll give it a try and see how it turns out.

Joe

Michel Walsh said:
Hi,


Indeed, I would place it in the onCurrent event subroutine handler.
=================================
Private Sub Form_Current()

If Me.NewRecord then
Me.RecordNumber = null
Else
Me.RecordsetClone.Bookmark = Me.Bookmark
Me.RecordNumber = 1+ Me.RecordsetClone.AbsolutePosition
End if

End Sub
==================================


Note I added 1, since the absolute position starts at 0


Hoping it may help,
Vanderghast, Access MVP


Access Joe said:
Thanks Michel,

One question: I'm not really 'code savvy'. Where exactly would I paste
that
code you providede? I'm assuming I would create an unbound control and
place
it somewhere there.

Thanks again. I'm looking forward to seeing if it'll work.

Joe
Michel Walsh said:
Hi,


The AbsolutePosition property of the recordset supplies that information.
Get the clone, synchronize the bookmark, read the position:


With Me.RecordsetClone
.Bookmark = Me.Bookmark ' note the starting dot
RecordNumber = .AbsolutePosition ' again, don't miss the dot
End With




Hoping it may help,
Vanderghast, Access MVP


Hi all,

I have a surgical subform and I would like it to display the current
selected record number. For instance, if a selected patient had three
surgeries, I would like the subform to display something like this:
"Record 1
of 3"...."Record 2 of 3", etc.

I've figured out how to display the total count of records [=count(*)],
but
I can't figure out how to display the current record number being
viewed.
Any ideas?

Thanks everyone!
Joe
 
Top