Counting of records based on 3 combo boxes

venu_resoju

Registered User.
Local time
Tomorrow, 04:20
Joined
Dec 29, 2010
Messages
129
I have a form and its contain a "text box" for counting of records based on combo box of "cboEmpID". I am using this code in control source of "text box"

= DCount("[AttendanceStatus]", "Attendance", "EmpID ='" & cboEmpID.Text & "' AND AttendanceStatus='" & "Present" & "'")

and it is working fine.

But I want to modify this code to count records based on another 2 combo boxes which are "AtnMonth" and "AtnYear"

"cboEmpID" = represents EmpID's
"AtnMonth"= represents "AttendanceMonth" from "Attendance" Table
"AtnYear"= represents "AttendanceYear" from "Attendance" Table

I strucked here
Please anybody help me.Thanks in advance
 
You should know that the .Text property is only available in Access when *that* control has the focus. Me.cboEmpID.Text should be Me.cboEmpID.Value or just Me.cboEmpID since the .Value property is the default property for a control. Notice I have prepended the Me. qualifier for clarification here.
 
= DCount("[AttendanceStatus]", "Attendance", "EmpID ='" & cboEmpID.Text & "' AND AttendanceStatus='" & "Present" & "'")

and it is working fine.

But I want to modify this code to count records based on another 2 combo boxes which are "AtnMonth" and "AtnYear"
 
=DCount("[AttendanceStatus]","Attendance","EmpID ='" & [cboEmpID].[Text] & "' AND AttendanceMonth=" & [AtnMonth].[Text] & "' AND AttendanceYear= " & [AtnYear].[Text] & "' AND AttenanceStatus=" & "Present" & "'")

I am using this code in control property but it is not working..please give me some idea...
 
Like RuralGuy already explained, you can't use the .TEXT property unless that control has focus. Change TEXT to VALUE
 
I have Changed .TEXT to .VALUE, but also it is not working.

=DCount("[AttendanceStatus]","Attendance","EmpID ='" & [cboEmpID].[Value] & "' AND AttendanceMonth='" & [AtnMonth].[Value] & "' AND AttendanceYear='" & [AtnYear].[Value] & "'")
it is not working....please solve this .I strucked here.
Please give some ideas....
Thanks in advance...
 
Tell me what the data types of all the fields you've used are.
 
I have Changed .TEXT to .VALUE, but also it is not working.

=DCount("[AttendanceStatus]","Attendance","EmpID ='" & [cboEmpID].[Value] & "' AND AttendanceMonth='" & [AtnMonth].[Value] & "' AND AttendanceYear='" & [AtnYear].[Value] & "'")
it is not working....please solve this .I strucked here.
Please give some ideas....
Thanks in advance...
 
venu, I imagine you wrote your last post in error. Please see my last post.
 
I am here with attaching my DB. Please solve my problem..and give some suggestions..

Thanks in advance...
 

Attachments

If I wanted to see your db I would have mentioned so. All I need to know is what are the data types of the fields you've used?
 
the data types of the fields I've used in the "Attendance" table are "text".
 
Even EmployeeID is Text too?

Does your table have a primary key (by the way)?

AttendanceMonth and AttendanceYear should be combined into one Date/Time field. From that field you can use the functions Month() and Year() or even Format([DateField], "m/yyyy") to query based on the Month and Year of that field. Do you have such a field?
 
Actually I want to count "No of Working Days" and "No of worked Day" (which are "Present" Days) of a selected person(in "EmpID" combo box) in a particular month.

How can I do?
 
Ok
Even EmployeeID also Text field.
"Attendance" table have a primary key, the primary key field is "AttendanceID"
I have such a field like month and year combined into one Date/Time field.
 
I don't have such a field like month and year combined into one Date/Time field.
 

Users who are viewing this thread

Back
Top Bottom