Topic: Need help for Calculated field

Can any one tell how to create calculated Field using count function for specific data of a field in combobox. For Example I have a form which have a combobox which have data Class one, Class Two, Class three and so on. A field 'Class' created for combobox in a Table Attendance. Next To combobox there is Text1. Now I want to display how many student were present on a date using count function.
How it will be?

2 (edited by brian.zaballa 2020-09-10 05:21:18)

Re: Need help for Calculated field

Here's a sample.

Post's attachments

Attachment icon SampleCalculated.zip 497.59 kb, 291 downloads since 2020-09-10 

brian

Re: Need help for Calculated field

Thank you Brain
Would you like to tell how did you create relationship field? id_student  because I am getting error message?

Re: Need help for Calculated field

What error are you getting at?

It is just a relationship created by MVD DB Designer.

brian

Re: Need help for Calculated field

Yes it is relationship created by MVD DB Design but I receive this error message "Cannot add a REFFERENCES column with non-Null default value"

Re: Need help for Calculated field

Uncheck Not Null and set Default value as empty. Creating a not null relationship to a table that already have data will give you that error.

Post's attachments

Attachment icon unforgettable.png 5.33 kb, 117 downloads since 2020-09-25 

brian

Re: Need help for Calculated field

Thank you brain to reply. I did what you have typed but still error. I am attaching your project look at it. Second I am attaching a pic. There is one date 9/10/2020 but result is showing separate result four time not one. I want to get the result in one time. How it will be? Obviously on this date in class one 6 students were present. So under Present heading it must be 6 not 3,1,1,1. I am sure you will understand what I want.

Post's attachments

Attachment icon Brain.png 23.34 kb, 105 downloads since 2020-09-25 

Re: Need help for Calculated field

look at your project and what error is there.

Post's attachments

Attachment icon SampleCalculated1.zip 328.84 kb, 225 downloads since 2020-09-25 

9 (edited by brian.zaballa 2020-09-25 17:56:02)

Re: Need help for Calculated field

I think you're missing the point of my database structure. I used a normalized many-to-many approach with it.

If you want to add student attending to a class on a specific date, you have to open(create if doesn't exists) the attendance with that class and date, then add the student there.

I've added a trap in adding an attendance. You don't need to add another record for attendance with the same class and date for it is considered as 1 record only. One record with many students attending to it.

For the relationship. I don't understand what's going on with that error you encountered in creating a relationship. It's working fine in my sample.

Post's attachments

Attachment icon SampleCalculated2.zip 498.79 kb, 257 downloads since 2020-09-25 

brian

10 (edited by unforgettable 2020-09-26 21:12:57)

Re: Need help for Calculated field

Thank you Brain. I got an idea. Would you to tell how to get print.

11 (edited by brian.zaballa 2020-09-27 04:25:34)

Re: Need help for Calculated field

That's one tricky part in MVD. I encountered a problem before when printing a many-to-many junction table.

My solution to it was to add another field, a relationship (redundant tho when normalizing a database but works) to the junction table.
I've added id_class to attendingStudent to display class name in the report.

Then i've added a disabled(you can hide it) text field on attendance form to filter the report from attendingStudents.

Post's attachments

Attachment icon SampleCalculatedPrintReport.zip 501.02 kb, 291 downloads since 2020-09-27 

brian