By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,107 Members | 904 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,107 IT Pros & Developers. It's quick & easy.

Counting records in open subform. Code updating nonstop

100+
P: 547
When i use this code to count the number of records on display in a specific subform in the "txtRecordNo" field that is open now, it seems to "update" all the time as the cursor changes every second and i am unable to add new records on mainform, untill i click in one of the fields of this Subform. Then it settles down. Otherwise it works 100% when i add records in the subform.
pls help

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.  
  3.     Dim rst As DAO.Recordset
  4.     Dim lngCount As Long
  5.  
  6.     Set rst = Me.RecordsetClone
  7.  
  8.     With rst
  9.         .MoveFirst
  10.         .MoveLast
  11.         lngCount = .RecordCount
  12.     End With
  13.  
  14. 'Show the result of the record count in the text box (txtRecordNo)
  15.  
  16.     Me.txtRecordNo = lngCount
  17. End Sub
Nov 24 '10 #1

✓ answered by TheSmileyCoder

You should remember to include a
Set rst=nothing
at the end of your code. However this has nothing to do with the issue at hand.
Do you have other code running in main form or subform?
Which version of access are you using?

Share this Question
Share on Google+
1 Reply

TheSmileyCoder
Expert Mod 100+
P: 2,321
You should remember to include a
Set rst=nothing
at the end of your code. However this has nothing to do with the issue at hand.
Do you have other code running in main form or subform?
Which version of access are you using?
Nov 24 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.