Leigh46137
Registered User.
- Local time
- Today, 15:28
- Joined
- Dec 29, 2009
- Messages
- 12
I’m working on an Access 2007 database. The table named “Transactions” contains the fields: “TranType” (text), “Amount” (currency) and “ClientID” (number).
The query named “qTransactionSumm" groups by TranType and sums the Amount.
When the user selects a client on a form (lstSelection combo box), I want to run the query selecting only the transactions for the selected client, then plug the total invoices and total receipts into text boxes on the form. Relevant code looks like this:
stSQL = "SELECT * FROM [qTransactionSumm] WHERE [ClientID] = " & Me.lstSelection
Set rs = db.OpenRecordset(stSQL)
Do While Not rs.EOF
Select Case rs![TranType]
Case Is = "Invoice"
Me.txtInvoiceTotal = rs![SumOfAmount]
Case Is = "Receipt"
Me.txtReceiptTotal = rs![SumOfAmount]
End Select
rs.MoveNext
Loop
In the query, I tried adding the ClientID field and setting the “Total” line to “Where”, but when I save the query, it removes that field – preventing me from running the query with the where clause.
I tried setting the criteria line for ClientID to 1 in the query and saving it, but when I run the above code, it says “Too few parameters. Expected 1” when opening the recordset.
Anyone know a way around this?
The query named “qTransactionSumm" groups by TranType and sums the Amount.
When the user selects a client on a form (lstSelection combo box), I want to run the query selecting only the transactions for the selected client, then plug the total invoices and total receipts into text boxes on the form. Relevant code looks like this:
stSQL = "SELECT * FROM [qTransactionSumm] WHERE [ClientID] = " & Me.lstSelection
Set rs = db.OpenRecordset(stSQL)
Do While Not rs.EOF
Select Case rs![TranType]
Case Is = "Invoice"
Me.txtInvoiceTotal = rs![SumOfAmount]
Case Is = "Receipt"
Me.txtReceiptTotal = rs![SumOfAmount]
End Select
rs.MoveNext
Loop
In the query, I tried adding the ClientID field and setting the “Total” line to “Where”, but when I save the query, it removes that field – preventing me from running the query with the where clause.
I tried setting the criteria line for ClientID to 1 in the query and saving it, but when I run the above code, it says “Too few parameters. Expected 1” when opening the recordset.
Anyone know a way around this?