counting fields

  • Thread starter Thread starter JohnE
  • Start date Start date
J

JohnE

I have a form that users are tracking performance
information. There are 14 categories and the response is
either Yes/No/NA. There is one performance record showing
on the form. They would like to know how many Yes, No,
and NA there are for the one record showing. Then from
there a fourth one showing the score. Which is all Yes
divided by all Yes + No to 2 decimal places. Can someone
show me a sample start for just counting the numbers and I
should be able to complete the rest.
Thanks.
*** John
 
Hi John,

Being that the database is NOT normalized you can loop thru the controls on
your Form using VBA code. Example:


Dim ctl As Control
Dim TotalYes As Integer, TotalNo As Integer, TotalNA As Integer

For Each ctl In Me.Controls
If TypeOf ctl Is TextBox Then
If ctl.Value = -1 Then
TotalYes = TotalYes + 1
ElseIf ctl.Value = 0 Then
TotalNo = TotalNo + 1
ElseIf ctl.Value = "NA" Then
TotalNA = TotalNA + 1
End If
End If
Next ctl

MsgBox "Yes = " & TotalYes & " No = " & TotalNo & " NA = " & TotalNA


I hope this helps! If you have additional questions on this topic, please
respond back to this posting.


Regards,

Eric Butts
Microsoft Access Support
(e-mail address removed)
"Microsoft Security Announcement: Have you installed the patch for
Microsoft Security Bulletin MS03-026? If not Microsoft strongly advises
you to review the information at the following link regarding Microsoft
Security Bulletin MS03-026
<http://www.microsoft.com/security/security_bulletins/ms03-026.asp> and/or
to visit Windows Update at <http://windowsupdate.microsoft.com/> to install
the patch. Running the SCAN program from the Windows Update site will help
to insure you are current with all security patches, not just MS03-026."

This posting is provided "AS IS" with no warranties, and confers no rights


--------------------
| Content-Class: urn:content-classes:message
| From: "JohnE" <[email protected]>
| Sender: "JohnE" <[email protected]>
| Subject: counting fields
| Date: Tue, 3 Aug 2004 14:15:43 -0700
| Lines: 11
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcR5nwkKAMO1/sXKQyGc872OYfdo5A==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.access.formscoding
| NNTP-Posting-Host: tk2msftngxa13.phx.gbl 10.40.1.165
| Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: cpmsftngxa10.phx.gbl microsoft.public.access.formscoding:240979
| X-Tomcat-NG: microsoft.public.access.formscoding
|
| I have a form that users are tracking performance
| information. There are 14 categories and the response is
| either Yes/No/NA. There is one performance record showing
| on the form. They would like to know how many Yes, No,
| and NA there are for the one record showing. Then from
| there a fourth one showing the score. Which is all Yes
| divided by all Yes + No to 2 decimal places. Can someone
| show me a sample start for just counting the numbers and I
| should be able to complete the rest.
| Thanks.
| *** John
|
 
Back
Top