Record "x" of "y"

S

Stuart

How to capture this simple bit of info is escaping me.
It appears that me.currentrecord captures the "x" when a
form is being displayed, but I can't figure out how to
capture "y".

Thanks, Stuart
 
B

Bruce M. Thompson

How to capture this simple bit of info is escaping me.
It appears that me.currentrecord captures the "x" when a
form is being displayed, but I can't figure out how to
capture "y".

One approach is to place an unbound textbox on your form and set its "Control
Source" to:

=[Form].CurrentRecord & " of " & [Form].RecordsetClone.RecordCount

In the form's "OnOpen" event procedure, you would need to enter the following
line to ensure a correct count (for "y"):

Me.RecordsetClone.MoveLast

The textbox will update itself as you move from record to record.
 
S

Stuart

Bruce, thanks. But... I still have a problem.

Perhaps I should have mentioned that this is in a
subform. It initially sets "y" correctly, but it behaves
very strangely if I move to another record on the main
form. And doesn't seem to be working after deletes
either. Any thoughts?

Thanks, Stuart
-----Original Message-----
How to capture this simple bit of info is escaping me.
It appears that me.currentrecord captures the "x" when a
form is being displayed, but I can't figure out how to
capture "y".

One approach is to place an unbound textbox on your form and set its "Control
Source" to:

=[Form].CurrentRecord & " of " & [Form].RecordsetClone.RecordCount

In the form's "OnOpen" event procedure, you would need to enter the following
line to ensure a correct count (for "y"):

Me.RecordsetClone.MoveLast

The textbox will update itself as you move from record to record.

--
Bruce M. Thompson, Microsoft Access MVP
(e-mail address removed) (See the Access FAQ at http://www.mvps.org/access)within the newsgroups so that all might benefit.<<


.
 
B

Bruce M. Thompson

Bruce, thanks. But... I still have a problem.
Perhaps I should have mentioned that this is in a
subform. It initially sets "y" correctly, but it behaves
very strangely if I move to another record on the main
form. And doesn't seem to be working after deletes
either. Any thoughts?

Try moving the code "Me.RecordsetClone.MoveLast" from the "OnOpen" event
procedure of the subform to the "OnCurrent" event procedure with the following
modification:

If Me.RecordsetClone.RecordCount Then
Me.RecordsetClone.MoveLast
End If

:)
 
S

Stuart

Bruce, that does not work. It calcs the number of
records in the subform correctly at first, but the
onCurrent code doesn't seem to cause it to recalculate.

Stuart
 
B

Bruce M. Thompson

Bruce, that does not work. It calcs the number of
records in the subform correctly at first, but the
onCurrent code doesn't seem to cause it to recalculate.

You did move it to the "OnCurrent" event procedure in the *subform*, didn't you.
It works for me when navigating or deleting records in both the main form and
the subform. Exactly what isn't working for you and when?
 
S

Stuart

Well it doesn't work for me. Can't imagine why. My
first main-form record has 5 subform records, the second
has 1. It comes up 5 and stays there no matter what I
do. Perhaps the fact that it's an .ADP has something to
do with it....

Having said that, I am working around the problem by
setting the control source = count([xyz]) where xyz is
any control in the subform. This gives me the subform
recordcount, if a tad slowly, so I guess I will use that
for now.

Clearly there is some "hidden property" that is giving
Access the answer. Guess we'll never find out what it
is, for now anyways.

Regards, Stuart
 
B

Bruce M. Thompson

Perhaps the fact that it's an .ADP has something to
do with it....

It might, but I'm not really familiar with ADPs.
Having said that, I am working around the problem by
setting the control source = count([xyz]) where xyz is
any control in the subform. This gives me the subform
recordcount, if a tad slowly, so I guess I will use that
for now.

Clearly there is some "hidden property" that is giving
Access the answer. Guess we'll never find out what it
is, for now anyways.

Glad you found a workaround. I guess I'm going to have to break down and do some
experimenting. <g>
 
J

John Spencer (MVP)

The First line looks as if it may be the problem. The comparison could be
failing. I might drop the IF clause and just do the move last.

If Me.RecordsetClone.RecordCount Then
Me.RecordsetClone.MoveLast
End If

Bruce M. Thompson said:
Perhaps the fact that it's an .ADP has something to
do with it....

It might, but I'm not really familiar with ADPs.
Having said that, I am working around the problem by
setting the control source = count([xyz]) where xyz is
any control in the subform. This gives me the subform
recordcount, if a tad slowly, so I guess I will use that
for now.

Clearly there is some "hidden property" that is giving
Access the answer. Guess we'll never find out what it
is, for now anyways.

Glad you found a workaround. I guess I'm going to have to break down and do some
experimenting. <g>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top