473,378 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Counting of records in subform causes a problem

547 512MB
If i use the code below to get the number of records in a subform , and i also use DoCmd.RunCommand acCmdRefresh to refresh screen, then the application stops working (the cursor never stops working). Any suggestions please?I have an unbound textbox (txtRecordNo3)in subform and another one on mainform to see no of records.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. On Error GoTo Form_Current_Err
  3. ' Provide a record counter for using with
  4. ' custom navigation buttons (when not using
  5. ' Access built in navigation)
  6.  
  7.   Dim rst As DAO.Recordset
  8.    Dim lngCount As Long
  9.  
  10.  Set rst = Me.RecordsetClone
  11.  
  12.  With rst
  13.      .MoveFirst
  14.   .MoveLast
  15.    lngCount = .RecordCount
  16.    End With
  17.  
  18. 'Show the result of the record count in the text box (txtRecordNo)
  19.  
  20.  Me.txtRecordNo3 = lngCount
  21.  Set rst = Nothing
  22. Form_Current_Exit:
  23.     Exit Sub
  24.  
  25. Form_Current_Err:
  26.     MsgBox Error$
  27.     Resume Form_Current_Exit
  28. End Sub
Mar 3 '11 #1
3 2215
colintis
255 100+
First thing there's no need to place .MoveFirst and .MoveLast as they seem pointless.

Second, if this part of the code is written within the main form, then u'll need to point out more specifically to the textbox in the subform
Me.SubformControlName.Form.TextBox
OR:
Me!SubformControlName.Form!TextBox
Mar 4 '11 #2
neelsfer
547 512MB
i removed the above code as it worked until you refresh the form.
Then I struggled with =count(*) etc and nothing worked. Then i read on allenbrowne.com that it is one of the Access 2007 bugs.
Eventually this code worked in Access 2007 to add a record count
Expand|Select|Wrap|Line Numbers
  1. =DCount("[any fieldname]","query name")
i then linked this to the main form to display number of records
Mar 4 '11 #3
Rabbit
12,516 Expert Mod 8TB
The .MoveLast is necessary to get a correct record count.
Mar 4 '11 #4

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

Similar topics

2
by: N. Graves | last post by:
I have a table with records of games played with a field for players name and another fields is a "WinorLose". One player may play several games to complete a match. I want my report to tell me...
5
by: chrisc | last post by:
Hello, Hope this is the right place for this... I am creating a testing database for components as they come off a production line. My reports need to select faults that are found, as well...
1
by: Nick via AccessMonster.com | last post by:
Hello, I'm using a form that has a subform. The subform is linked to a hidden datasheet form, and the subform displays records from the form. The problem is, the subform will only show X...
2
by: allyn44 | last post by:
Hello, I have built a serch form for users to edit records. I only want them to pull up the record they need, and I want to check for nulls. There should not be dupes becasue the underlying...
14
by: (PeteCresswell) | last post by:
I've got a form (frmDeal) that has a subform (frmDeal_Tranche) that has a subform (frmDeal_TrancheCusip). When I try to refer to properties on the "Cusip" form at the end of the chain, MS Access...
4
by: liverpoolrdbest | last post by:
Hi, I have a subform in my form, but when you fill it in it updates the entered data on each of my forms records. Is there a way to stopping it doing this and making each of the forms records an...
4
by: Ecohouse | last post by:
have a main form with two tabs, and each tab has a subform. The first tab's subform refers to the mainform (this works). The second tab's subform refers to the identity key of the first tab's...
11
by: mrowe | last post by:
I am using Access 2003. (I am also using ADO in the vast majority of my code. I recently read a post that indicated that ADO is not all that is was initially cracked up to be. In the back of my...
8
by: crassostrea | last post by:
Hello and Happy New Year, I have two tables in Access 2003 (Windows XP) with similar, but different, information. We’ll call them table A and table B. I want to count the number of records in...
10
by: Chinde | last post by:
Hi I'm having problems with a subform, I'm using access 2007 but the DB's format is 2003, running os Xp. This is the problem, I have a main form which is set to be a single form and will auto...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.