Get count of rows in subform programmatically

  • Thread starter Jonathan Scott via AccessMonster.com
  • Start date
J

Jonathan Scott via AccessMonster.com

I am trying to get the number of rows in a subform programmatically. The Form.
Count should be returning 0, but for some reason is coming up 8. Why, I
cannot understand, as when I try it manually, it comes up 0!

Is there some better way for me to get the row count of a subform
programmatically?

Jonathan Scott
 
A

Allen Browne

Examine the RecordCount of the RecordsetClone of the Form in the subform
control.

The full reference will be something like this:
Forms!frmInvoice!frmInvoiceDetail.Form.RecordsetClone.RecordCount

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

message
news:[email protected]...
 
J

Jonathan Scott via AccessMonster.com

Works beautifully! Thank you very much!

Jonathan Scott


Allen said:
Examine the RecordCount of the RecordsetClone of the Form in the subform
control.

The full reference will be something like this:
Forms!frmInvoice!frmInvoiceDetail.Form.RecordsetClone.RecordCount
I am trying to get the number of rows in a subform programmatically. The
Form.
[quoted text clipped - 3 lines]
Is there some better way for me to get the row count of a subform
programmatically?
 
J

Jonathan Scott via AccessMonster.com

Hmmmmm, seems I am not getting what I had expected. I get the recordset of
the subform, and can confirm it, however, I seem to be unable to get what the
user actually sees. Without a [Form].requery(), the method below gives me
back the just added rows, but when I try it at the user interface, those rows
that should be there don't show up.

Is it possible to get what the USER sees, as opposed to what the subform has
but may or may not be displaying?

Jonathan Scott


Allen said:
Examine the RecordCount of the RecordsetClone of the Form in the subform
control.

The full reference will be something like this:
Forms!frmInvoice!frmInvoiceDetail.Form.RecordsetClone.RecordCount
I am trying to get the number of rows in a subform programmatically. The
Form.
[quoted text clipped - 3 lines]
Is there some better way for me to get the row count of a subform
programmatically?
 
A

Allen Browne

I'm not clear about the question, Jonathan, but it might be a timing issue.

Is your code running in an event when the records have not loaded yet?
Could you use a different event?

Or would you prefer to use a DCount() directly on the subform's table to get
the number of related records? That would work even if there is a Filter
applied to the subform, it is opened in DataEntry mode, or you can't find a
suitable event.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

message
Hmmmmm, seems I am not getting what I had expected. I get the recordset of
the subform, and can confirm it, however, I seem to be unable to get what
the
user actually sees. Without a [Form].requery(), the method below gives me
back the just added rows, but when I try it at the user interface, those
rows
that should be there don't show up.

Is it possible to get what the USER sees, as opposed to what the subform
has
but may or may not be displaying?

Jonathan Scott


Allen said:
Examine the RecordCount of the RecordsetClone of the Form in the subform
control.

The full reference will be something like this:
Forms!frmInvoice!frmInvoiceDetail.Form.RecordsetClone.RecordCount
I am trying to get the number of rows in a subform programmatically. The
Form.
[quoted text clipped - 3 lines]
Is there some better way for me to get the row count of a subform
programmatically?
 
J

Jonathan Scott via AccessMonster.com

The problem is not with the underlying table. That is getting updated in a
proper time frame. The problem is that the table is updated, the recordset of
the control is updated, but what the user sees is not. In other words, I am
getting a false-positive. I would like to confirm the screen contains the
proper data, not that the control or table is properly updated.

Jonathan Scott


Allen said:
I'm not clear about the question, Jonathan, but it might be a timing issue.

Is your code running in an event when the records have not loaded yet?
Could you use a different event?

Or would you prefer to use a DCount() directly on the subform's table to get
the number of related records? That would work even if there is a Filter
applied to the subform, it is opened in DataEntry mode, or you can't find a
suitable event.
Hmmmmm, seems I am not getting what I had expected. I get the recordset of
the subform, and can confirm it, however, I seem to be unable to get what
[quoted text clipped - 21 lines]
 
A

Allen Browne

So the problem is not that the code is returning the wrong value, but that
continuous subform has records that are scrolled up out of view?

If that is the case, the issue might be to identify what is scrolling it
(such as a Find). Or Stephen Lebens' code for manipulating the scrollbar
might help:
http://www.lebans.com/SelectRow.htm

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

message
The problem is not with the underlying table. That is getting updated in a
proper time frame. The problem is that the table is updated, the recordset
of
the control is updated, but what the user sees is not. In other words, I
am
getting a false-positive. I would like to confirm the screen contains the
proper data, not that the control or table is properly updated.

Jonathan Scott


Allen said:
I'm not clear about the question, Jonathan, but it might be a timing
issue.

Is your code running in an event when the records have not loaded yet?
Could you use a different event?

Or would you prefer to use a DCount() directly on the subform's table to
get
the number of related records? That would work even if there is a Filter
applied to the subform, it is opened in DataEntry mode, or you can't find
a
suitable event.
Hmmmmm, seems I am not getting what I had expected. I get the recordset
of
the subform, and can confirm it, however, I seem to be unable to get
what
[quoted text clipped - 21 lines]
Is there some better way for me to get the row count of a subform
programmatically?
 
Top