combo box selection runs query to sum values in table not gettingparameter from combo box

R

RCGUA

I have two tables, one with Workers Names and the other table has the
Workers Payments
I have a form with a combo box listing the Workers Names. I would
like to selection a workers name from the combo box and then fill a
text box with the sum of all the payments the worker has made.

In the AfterUpdate event for the combo box I have: =========

Private Sub cboWorkerName_AfterUpdate()
DoCmd.OpenQuery "qryTotalPaymentsByWorker3", acReadOnly
End Sub

After updating the combo box, it runs a query to sum they
PaymentAmounts -however- the query pops up a box asking for the
workers name. I want the query to get the WorkersName from the combo
box.

====SQL View of the query=========

SELECT DISTINCTROW tblPayments.WorkerName, Sum
(tblPayments.PaymentAmount) AS [Sum Of PaymentAmount]
FROM tblPayments
WHERE (((tblPayments.WorkerName)=[frmCASA-4payments]![cboWorkerName]))
GROUP BY tblPayments.WorkerName;
 
K

KARL DEWEY

Try this --
WHERE (((tblPayments.WorkerName)=[Forms]![frmCASA-4payments]![cboWorkerName]))
 
R

RCGUA

Try this --
WHERE (((tblPayments.WorkerName)=[Forms]![frmCASA-4payments]![cboWorkerName]))

--
Build a little, test a little.



RCGUA said:
I have two tables, one with Workers Names and the other table has the
Workers Payments
I have a form with a combo box listing the Workers Names.  I would
like to selection a workers name from the combo box and then fill a
text box with the sum of all the payments the worker has made.
In the AfterUpdate event for the combo box I have: =========
Private Sub cboWorkerName_AfterUpdate()
DoCmd.OpenQuery "qryTotalPaymentsByWorker3", acReadOnly
End Sub
After updating the combo box, it runs a query to sum they
PaymentAmounts  -however- the query pops up a box asking for the
workers name.  I want the query to get the WorkersName from the combo
box.
====SQL View of the query=========
SELECT DISTINCTROW tblPayments.WorkerName, Sum
(tblPayments.PaymentAmount) AS [Sum Of PaymentAmount]
FROM tblPayments
WHERE (((tblPayments.WorkerName)=[frmCASA-4payments]![cboWorkerName]))
GROUP BY tblPayments.WorkerName;

Excellent! That fixed the problem. I left out the ~ [Forms] ~
also, I had to mess around with which column the combo box was bound
to, etc.

Thank You Very Much Karl !! I really appreciate your help.
 

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