Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


counting yes/no fields in a table

Posted on 2003-03-07
Medium Priority
Last Modified: 2006-11-17
Hi, I need to count the number of times a field in 'table1' is true for a specific form 'id' (from table2).
This value needs to be stored as an integer.
Any ideas?
I have tried both of these but they return errors.
where table1 = ukcShapeData and table2 = ResearchInToDCD.

'Forms!ResearchIntoDCD![NoOfShapesPassed] = DCount("[ShapePassed] ", "[UKCShapeData]", "[SubjectNum] = Forms!ResearchIntoDCD![subject number]"And [UKCShapeData]![ShapePassed]=Yes)

Forms!ResearchIntoDCD![NoOfShapesPassed] = IIf(ShapePassed = Yes, DCount("*", "[UKCShapeData]", "[SubjectNum] = Forms!ResearchIntoDCD![subject number]"), 1)
Question by:simonpgill
  • 2
  • 2

Accepted Solution

phL earned 300 total points
ID: 8088601
You may have been close with your first attempt -

'Forms!ResearchIntoDCD![NoOfShapesPassed] = DCount("[ShapePassed] ", "[UKCShapeData]", "[SubjectNum] = Forms!ResearchIntoDCD![subject number]"And [UKCShapeData]![ShapePassed]=Yes)

However, the syntax needs work.  Try -

Forms!ResearchIntoDCD![NoOfShapesPassed] = DCount("[ShapePassed] ", "[UKCShapeData]", "[SubjectNum] = " & Forms!ResearchIntoDCD![subject number] & " And [UKCShapeData]![ShapePassed] = Yes")


Author Comment

ID: 8088609
The problem has been solved. The solution is

Forms!ResearchIntoDCD![NoOfShapesPassed] = DCount("[ShapePassed] ", "[UKCShapeData]", "[SubjectNum] = Forms!ResearchIntoDCD![subject number] And [UKCShapeData]![ShapePassed]=Yes")

If anyone else tries this.
This code works.

Author Comment

ID: 8088621
cheers Phill we just worked it out also but you can have the points anyway.

Expert Comment

ID: 8088650
Spaces and Quotes and building strings always give me problems until I have my AM coffee.

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question