Sum & Count on Form.

C

Chiki

i had a form on which i had created a combo box that contain several employees.

I want the amount earned (Currency Format) by each employee to be displayed
on the formin the text box.

Other fields in my table are;

Empid,Empname,amount earned.etccc

please tell me how to solve this.
 
C

Chiki

I mean i want the sum to be displayed in the text box whenever i select an
employee from the combo box.
 
J

John W. Vinson

i had a form on which i had created a combo box that contain several employees.

I want the amount earned (Currency Format) by each employee to be displayed
on the formin the text box.

Other fields in my table are;

Empid,Empname,amount earned.etccc

please tell me how to solve this.

Well, it's a bit hard to be sure given the sparse information, but try setting
the control source of the textbox to

=DSum("[Amount Earned]", "tablename", "[EmpID] = " & [EmpID])
 
C

Chiki

Is it so difficult???

Please tell me what other information do i need to provide

Thanks
 
J

John W. Vinson

Is it so difficult???

Please tell me what other information do i need to provide

Thanks

Did you see my previous answer?

try setting the control source of the textbox to

=DSum("[Amount Earned]", "tablename", "[EmpID] = " & [EmpID])
 
C

Chiki

Yes, i had tried using the formula u had given.

Its returning an #Error Message.I dont know why.I think i had to check out
the exact syntax or check the correct text box names.

Thanks.
 
J

John W. Vinson

Yes, i had tried using the formula u had given.

Its returning an #Error Message.I dont know why.I think i had to check out
the exact syntax or check the correct text box names.

Thanks.

Well... yes.

I cannot see your screen. I do not know the name of your table; you should use
it in place of "tablename". Likewise you need to specify the correct
fieldnames... which, again, I do not know.

If you'll post some more details about your table (table name, fieldnames,
datatypes of those fields, form control names) someone should be able to help.
 
C

Chiki

Ok.Sorry if i had missed anything.

I had created a table named EMP. The Table consists of the fields:-

Emp id-Autonumber
Employee Name-Text
Date of Joining-Date/time
Days worked-Number
Amount Earned-Currency.

On the form,i had created the combo box named:Employee Name

and text boxes named;Date of Joining,amt earned & Days worked.

Please tell me now what to change in my code;
 
J

John W. Vinson

Ok.Sorry if i had missed anything.

I had created a table named EMP. The Table consists of the fields:-

Emp id-Autonumber
Employee Name-Text
Date of Joining-Date/time
Days worked-Number
Amount Earned-Currency.

On the form,i had created the combo box named:Employee Name

and text boxes named;Date of Joining,amt earned & Days worked.

Please tell me now what to change in my code;

Set the Control Source property of the textbox [amt earned] to

=DSum("[Amount Earned]", "[EMP]", "[Emp id] = " & [Employee Name])

This assumes (again, perhaps incorrectly, I don't know) that the Employee Name
combo box is displaying a name but has the Emp ID as its control source and
bound column.
 
C

Chiki

I did not get u..How could i use the Control source of Employee Name as EMP Id.

I could not understand the syntax also.
 
J

John W. Vinson

I did not get u..How could i use the Control source of Employee Name as EMP Id.

I could not understand the syntax also.

Please open the form in design view.

Select the Employees combo box.

View its Properties.

Post the following properties to a message here:

- Rowsource (where the combo box gets its information) - post the SQL view if
it is a query
- Control Source (where it puts the data when you select a row)
- Bound Column (which field from the rowsource it stores in the control
source)

The syntax of DSum is that it takes three text strings as arguments. The first
text string is the field that it sums; the second is the name of the table or
query containing the field; the third is an optional criterion specifying
which records to sum. So

=DSum("[Amount Earned]", "[EMP]", "[Emp id] = " & [Employee Name])

means look in the table EMP; select those records where the [Emp id] field is
equal to the value contained in the form control named [Employee name] - which
I'm hoping is the employee ID; and when you find those records, sum up the
numbers in the field named [Amount Earned] and return that sum as the result
of the function.
 
C

Chiki

Ok then.

I had built the table tblEmp with fields

Emp id -Auto Number
Emp Name- Text
Date of Joining -Date/time.
Days worked- Number
Amount earned-Currency

Regarding the

RowSource:i had created a SQL Query name qryemp,where the query returned
only the Employees name from tblemp

Control Source:=DSum("[Amount Earned]","[EMP]","[Emp id] = " & [Emp Name])

Bound Column:not sure which column i should refer 2/5.

Also , please tell me ,can i upload the file to your reference.

Thanks in advance.....
 
C

Chiki

I had followed all the steps you had told me.

Applied the same Control source property of the text box (amount Earned)

still getting ERRORS............
 
J

John W. Vinson

I had followed all the steps you had told me.

Applied the same Control source property of the text box (amount Earned)

still getting ERRORS............

Chiki...

My crystal ball is very foggy tonight.

I cannot see your database.

You have not been communicating.

Please post (as requested!) the names AND DATATYPES of the fields involved.
Please post (as requested!) your actual code.
Please post the actual text of your error message.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top