thardyjackson
Registered User.
- Local time
- Yesterday, 16:34
- Joined
- May 27, 2013
- Messages
- 45
I have a calculated field [pmtSumAfterPmt] that’s a running total of payments for each customer. It's based on DSUM. It is super slow -- as a point of reference, adding that one field to the query causes an Excel export of 1500 results to take 6 minutes instead of 3 seconds; viewing the results in the table is very sluggish. I'm wondering if there's a better approach or maybe I've botched something up.
Here's the basic structure:
* tbl_customer (300 records) --- basic information on customers (name, account #, etc.)
* tbl_payments (1500 records) -- information downloaded from our bank (payment amount, payment date, customer account # manually typed by customer, etc.) - it also has a [nbrCustAcctOverride] field I can later use if customer mistyped account number or I want to ignore the transaction.
* qry_pmtTblProcessing -- a cleaned up version of tbl_payments which categorizes transactions, removes spaces from account numbers, applies any overrides, etc.
* qry_pmtRcptAnalysis -- joins tbl_customer and qry_pmtTblProcessing so I can compare whether customer is on track with their payments. An important field is [pmtSumAfterPmt] which is the running total of payments for each customer. I need to know this value after each payment. It's the only "D" function in these 2 queries.
FYI -- the reason I join on a qry instead of a table is that I need to process the info in the tbl_payments table before doing the join.
A snippet of qry_pmtRcptAnalysis is below.
Here's the basic structure:
* tbl_customer (300 records) --- basic information on customers (name, account #, etc.)
* tbl_payments (1500 records) -- information downloaded from our bank (payment amount, payment date, customer account # manually typed by customer, etc.) - it also has a [nbrCustAcctOverride] field I can later use if customer mistyped account number or I want to ignore the transaction.
* qry_pmtTblProcessing -- a cleaned up version of tbl_payments which categorizes transactions, removes spaces from account numbers, applies any overrides, etc.
* qry_pmtRcptAnalysis -- joins tbl_customer and qry_pmtTblProcessing so I can compare whether customer is on track with their payments. An important field is [pmtSumAfterPmt] which is the running total of payments for each customer. I need to know this value after each payment. It's the only "D" function in these 2 queries.
FYI -- the reason I join on a qry instead of a table is that I need to process the info in the tbl_payments table before doing the join.
A snippet of qry_pmtRcptAnalysis is below.
Code:
[FONT=Courier New]SELECT qry_pmtTblProcessing.*, tbl_customers.*,[/FONT]
[FONT=Courier New]CDbl(DSum("[pmtCompletedInOut]","qry_pmtTblProcessing","CDbl([pmtDate]) <= " & CDbl([pmtDate]) & " And [nbrCustAcctUsed]='" & [nbrCustAcctUsed] & "'")) AS pmtSumAfterPmt,[/FONT]
[FONT=Courier New][ NOTE: A few other calculations omitted ][/FONT]
[FONT=Courier New]FROM qry_pmtTblProcessing LEFT JOIN tbl_customers ON qry_pmtTblProcessing.nbrCustAcctUsed=tbl_customers.nbrCustAcct;[/FONT]