473,396 Members | 2,076 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,396 software developers and data experts.

MSACCESS help in counting text values

I'm new to Access and need some help if possible. I have a report that I'm trying to build from a table. The table lists students in a class. The table contains the usual fields such as name, class, address, state, etc. Becasue I need to know if the students were present or absent on certain dates, I made the dates fields in the table. I want to be able to count the number of dates each student was present and absent on a report. The value that I'm usinf in the date fields is "P" for present and "A" for absent. How do I tell Access to tell me how many "P"s and how many"A"s for a series of dates? How do I count non-numeric values from a field?
Thanks
Sep 23 '07 #1
4 3707
Scott Price
1,384 Expert 1GB
I'm new to Access and need some help if possible. I have a report that I'm trying to build from a table. The table lists students in a class. The table contains the usual fields such as name, class, address, state, etc. Becasue I need to know if the students were present or absent on certain dates, I made the dates fields in the table. I want to be able to count the number of dates each student was present and absent on a report. The value that I'm usinf in the date fields is "P" for present and "A" for absent. How do I tell Access to tell me how many "P"s and how many"A"s for a series of dates? How do I count non-numeric values from a field?
Thanks
Hi there, and welcome to the Scripts!

You can use the DCount(expr ,domain ,[criteria] ) function to count the occurrences of any value (text included) of a field.

To give you any more specific help we'll need to know a few more things about the structure of your table. Specifically, you say that the date field contains the P and A values? In what format, then, is the date stored?

Please post your table structure. Please include the MetaData for all relevant datasets. Here is an example of how to post table MetaData :

Table Name=tblStudent

Expand|Select|Wrap|Line Numbers
  1.           Field; Type; IndexInfo
  2. StudentID; AutoNumber; PK
  3. Family; String; FK
  4. Name; String
  5. University; String; FK
  6. Mark; Numeric
  7. LastAttendance; Date/Time
Regards,
Scott
Sep 23 '07 #2
ADezii
8,834 Expert 8TB
I'm new to Access and need some help if possible. I have a report that I'm trying to build from a table. The table lists students in a class. The table contains the usual fields such as name, class, address, state, etc. Becasue I need to know if the students were present or absent on certain dates, I made the dates fields in the table. I want to be able to count the number of dates each student was present and absent on a report. The value that I'm usinf in the date fields is "P" for present and "A" for absent. How do I tell Access to tell me how many "P"s and how many"A"s for a series of dates? How do I count non-numeric values from a field?
Thanks
  1. Restrict the Date Range in the Record Source for the Report.
  2. Create a Text Box in the Report Footer with a Label similar to: Total Students present:
  3. Copy and Paste this code to the Control Source of the Text Box:
    Expand|Select|Wrap|Line Numbers
    1. =DCount("*","<Report Record Source>","[Date]='P'")
  4. Create a Text Box in the Report Footer with a Label similar to: Total Students absent:
  5. Copy and Paste this code to the Control Source of the Text Box:
    Expand|Select|Wrap|Line Numbers
    1. =DCount("*","<Report Record Source>","[Date]='A'")
Sep 23 '07 #3
Hi there, and welcome to the Scripts!

You can use the DCount(expr ,domain ,[criteria] ) function to count the occurrences of any value (text included) of a field.

To give you any more specific help we'll need to know a few more things about the structure of your table. Specifically, you say that the date field contains the P and A values? In what format, then, is the date stored?

Please post your table structure. Please include the MetaData for all relevant datasets. Here is an example of how to post table MetaData :

Table Name=tblStudent

Expand|Select|Wrap|Line Numbers
  1.           Field; Type; IndexInfo
  2. StudentID; AutoNumber; PK
  3. Family; String; FK
  4. Name; String
  5. University; String; FK
  6. Mark; Numeric
  7. LastAttendance; Date/Time
Regards,
Scott

Thanks for the reply, I think I probaly need to start over; my table has the standard fields except I used the dates themselves as the field names in my table as seen below. On the report I wanted to show on the same row with each student, each day, and the status of their attendance. The finished report, I had hoped would have a row that shows name, class, sept 9, 2007, sept 16, 2007, etc. and the attendance value for each. Then at the end of the row for each student I would have the count of how many "P"s and the count of how many "A"s

Table Name=tblStudent
StudentID
LastName
FirstName
sept 9, 2007
sept 16, 2007
sept 30, 2007
Oct 1, 2007
etc
Sep 23 '07 #4
Scott Price
1,384 Expert 1GB
Thanks for the reply, I think I probaly need to start over; my table has the standard fields except I used the dates themselves as the field names in my table as seen below. On the report I wanted to show on the same row with each student, each day, and the status of their attendance. The finished report, I had hoped would have a row that shows name, class, sept 9, 2007, sept 16, 2007, etc. and the attendance value for each. Then at the end of the row for each student I would have the count of how many "P"s and the count of how many "A"s

Table Name=tblStudent
StudentID
LastName
FirstName
sept 9, 2007
sept 16, 2007
sept 30, 2007
Oct 1, 2007
etc
Hmm... I think you can easily see now how the structure you have artificially limits your capabilities, especially down the road! For example say you decide to add class days, or next year you need to change the dates. It will be a royal pain to have to go into your table and manually change each date field to correspond to the new class days.

However, there are other options :-) Probably the best one that I can think of right now is to create another table and call it Attendance (or tblAttendance if you want to use that naming convention). It will have these fields:

tblAttendance
AttendanceID Autonumber, PK
StudentID Number FK
ClassDate Date/Time
Attendance Text w/ validation rule: P, A

You can then delete from your Students table all the fields that refer to dates, and you will create a relationship between the StudentID field in tblStudents and the StudentID field in tblAttendance.

Now you can create a query that looks and counts each student's P's and A's quite easily.

Please read this tutorial on Database Normalisation and Table Structures also.

Regards,
Scott
Sep 23 '07 #5

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

Similar topics

14
by: Mike N. | last post by:
Hello: I have a form that contains a multiple-select field that has 12 options in it. I would like the user to be able to select UP TO FOUR of those options. If they select more than four, I...
15
by: (Pete Cresswell) | last post by:
I've got a .BAT file that I use for executing various MS Access apps that I wrote way back in the days of 2.0. It's evolved over time, but it still contains a number of possible paths to...
115
by: TheAd | last post by:
At this moment I use MsAccess and i can build about every databound application i want. Who knows about a serious open source alternative? Because Windows will be a client platform for some time, i...
0
by: http://www.visual-basic-data-mining.net/forum | last post by:
I am trying to connect to MsAccess 2000 database using ASP.NET. The code snippet is attached below. In the select statement, when I use a *, I get the values and they are populated in the drop down...
4
by: rudy | last post by:
I'm trying to insert text values into a table in a MSAccess DB the values are stored in string variables Imports System.Data.OleDb .... Dim name As String Dim position As String Dim site As...
11
by: Yelena Varshal via AccessMonster.com | last post by:
Hello, I have a problem with one of msaccess.exe API calls that work on my desctop but does not work on the laptop from within MS ACCESS. There is a lot of differences between 2 computers...
6
by: odbcmsaccess | last post by:
hi i 'm writng a code using msaccess with odbc. my dsn name is htgry i want to insert data eneterd in text fields to a table named qwer on clicking a command button. code as follows ...
2
by: tmarunkumarit | last post by:
I want to insert datetime values into msaccess using asp.net by vb.. Am getting error that Syntax Error in INSERT INTO statement... My query is strSQL="insert into group0...
3
by: Icemokka | last post by:
Hi, I've got a table in MsAccess with 100+ fields. If I fill a tabletable with this table , change some values , get the update-command via commandbuilder , the update fails. This because the...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.