M
Mark Andrews
I have a list box with three columns (AccountID, AccountName, OppDollars)
populated by this query:
SELECT tblAccount.AccountID, tblAccount.AccountName,
Sum(tblOpportunity.OppDollars) AS OppDollars
FROM tblAccount INNER JOIN tblOpportunity ON tblAccount.AccountID =
tblOpportunity.AccountID
GROUP BY tblAccount.AccountID, tblAccount.AccountName
HAVING (((Sum(tblOpportunity.OppDollars))>50000))
ORDER BY Sum(tblOpportunity.OppDollars) DESC;
I would now like to do the following:
- update the underlying tblAccount table and change a column named
"Sequence" to be the row number of the record in the list box.
So in summary:
- tblAccount has 10,000 records,
- the query above returns 450 records with accounts with over $50,000 of
opportunity dollars (sorted desc by oppdollars)
- I would like those 450 records to be updated in tblAccount with numbers 1
thru 450 (or 0 thru 449 would be fine as well)
Options I know:
- I could run through the records in the list box and run an update query
for each one (that seems like it might take a while).
I tried using DCOUNT in the above query to generate a sequence number but
can't get it to work? If I had that I could join this query to the table
and run an update query.
Thanks in advance for any help,
Mark
populated by this query:
SELECT tblAccount.AccountID, tblAccount.AccountName,
Sum(tblOpportunity.OppDollars) AS OppDollars
FROM tblAccount INNER JOIN tblOpportunity ON tblAccount.AccountID =
tblOpportunity.AccountID
GROUP BY tblAccount.AccountID, tblAccount.AccountName
HAVING (((Sum(tblOpportunity.OppDollars))>50000))
ORDER BY Sum(tblOpportunity.OppDollars) DESC;
I would now like to do the following:
- update the underlying tblAccount table and change a column named
"Sequence" to be the row number of the record in the list box.
So in summary:
- tblAccount has 10,000 records,
- the query above returns 450 records with accounts with over $50,000 of
opportunity dollars (sorted desc by oppdollars)
- I would like those 450 records to be updated in tblAccount with numbers 1
thru 450 (or 0 thru 449 would be fine as well)
Options I know:
- I could run through the records in the list box and run an update query
for each one (that seems like it might take a while).
I tried using DCOUNT in the above query to generate a sequence number but
can't get it to work? If I had that I could join this query to the table
and run an update query.
Thanks in advance for any help,
Mark