DCount field to be updated immediately

Andreas Hermle
Andreas Hermle used Ask the Experts™
on
Dear Experts:

I got an unbound text field on a form ...
.. that displays the number of occurrences in which the checkbox (chkAuthor) is checked off.

=DCount("[chkAuthor]";"tblArticle";"[chkAuthor]<>0")

It works correctly. How can I get Access to UPDATE this form field IMMEDIATELY after I have checked off another checkbox (chkAuthor).
Now I often have to move thru several records in the form till this field gets updated.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
In after update events for other controls on you form you can set velue for this field:
Me.SomeMyField = Count("[chkAuthor]";"tblArticle";"[chkAuthor]<>0")
DCount, of course
Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010
Commented:
is this in a continuous form?  If so, you put this other control in the forms footer and just use the following as the control source for that control.

= ABS(Sum([chkAuthor]))

Most Valuable Expert 2015
Distinguished Expert 2018
Commented:
You would, of course, use in the AfterUpdate event:

Me!txtCount.Requery

where txtCount is your textbox.

/gustav
Andreas HermleTeam leader

Author

Commented:
Dear cactus_data and als315:

thank you very much for your swift help. It works just fine but only if I put your snippet into the 'Form_Current' Procedure. The AfterUpdate event does not work with me. Maybe you got my question wrong.

Buy anyhow thank you very much for your great help with this code snippet.

Hi fyed: no it is not a continuous form. Should I use one in the future your code  snippet will come in handy.

Regards, Andreas
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
I meant the AfterUpdate event of the checkbox you check off.

/gustav
Andreas HermleTeam leader

Author

Commented:
Hi gustav,

ok, got it.

Thank you very much for your professional help.

Regards, Andreas
Andreas HermleTeam leader

Author

Commented:
Dear all,

it is always very hard for me to award points equitably since I can learn from every answer.

Again, thank you very much for your time taken and the valuable / professional help.

Regards, Andreas
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
You are welcome!

/gustav

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial