strange behaviour of text field

fra

Registered User.
Local time
Today, 17:16
Joined
Nov 12, 2012
Messages
12
Hi,
In my Access 2010 database there is a form with a large number of checkboxes enabling me to select/deselect certain record details.
Each click on one of the checkboxes triggers a VBA routine setting true/false values in one of several tables linked to the main table.
A query over all records is filtered by the true/false values of the linked tables and the resulting set of records is displayed in the (continuous) form.
The header of the form contains a text field with the value "=GetRecCount()" displaying (correctly, but randomly fast) the number of records selected:
Code:
Function GetRecCount() As String
  Dim NumRecs As Long
  Dim rs As Object
  On Error Resume Next
    Set rs = Forms![Super Search].RecordsetClone
    rs.MoveLast
    NumRecs = rs.RecordCount
    Set rs = Nothing
    GetRecCount = Format(NumRecs, "##,###")
End Function
Now, the funny thing is that each click on one of the boxes results in 1 call of the VBA routine setting table values, but 21 calls (!) of the text field "=GetRecCount()" in the form. I have established this by incrementing a public variable at each pass.
Can anyone explain, why a field in a form is updated 21 times when a filter is applied?

Fritz
 
Is there any event related code that is related to this text box being fired each time the event happens, such as on_Current

David
 
No, there isn't. The form has an event at opening (reset all checkboxes to default True), the checkboxes have events on_click as described and that's it.
The form functions exactly as designed and very fast, too. In fact, other than the bottom line showing "calculation running..." (or similar, I have the German version) and occasional random delays in displaying the text field value, I would not have suspected anything. It happens so fast that there even is no visible flicker of the form or the text field.
Fritz
 
Your code does this. What it is specfically we cannot guess. Make a stripped copy of your db, make sure you can reproduce the problem, attach it here with instructiosn how to see the problem. Save it as A2007 if you can - many are still on the older versions.
 
I finally killed the silly 21time repetition by removing the function as a field value and replacing it with an identical function triggered by "OnApplyFilter", writing the value directly into the text field. Now each click on a checkbox results in 1 (one!) update of the field, it is fast as hell, the values are correct and I could even add a small If/Then routine catching a zero value.
Fritz
 

Users who are viewing this thread

Back
Top Bottom