Update oldest first

  • Thread starter Thread starter jbiggs via AccessMonster.com
  • Start date Start date
J

jbiggs via AccessMonster.com

I have an update query that is assigning leads to salespeople based on what
percentage of leads are available for each source, that query looks like:

DoCmd.RunSQL "UPDATE clients SET salesperson = " & Text15 & " WHERE ID IN (
SELECT TOP " & NumLeads & " ID FROM clients WHERE Salesperson IS NULL And
[task note] = 'Unworked Lead' And Source = """ & CurrentSource & """) "

The issue is, the leads are assigned randomly and we have a bunch of old
leads backed up in the system. I tried to add ORDER BY [System Date] DESC at
the end of the query but it made things go haywire. Where do I need to add
the ORDER BY statement?
 
One way to "discover" this would be to copy the existing SQL statement into
a new query, then use the query design view to modify the sort order, before
returning to SQL view to see how Access converts it.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Hi Jeff,

I gave this a try but the problem is that it only creates 2 columns in design
view, one for the salesperson it is updated to and then the other column
contains the entire subquery.

Jeff said:
One way to "discover" this would be to copy the existing SQL statement into
a new query, then use the query design view to modify the sort order, before
returning to SQL view to see how Access converts it.

Regards

Jeff Boyce
Microsoft Office/Access MVP
I have an update query that is assigning leads to salespeople based on what
percentage of leads are available for each source, that query looks like:
[quoted text clipped - 10 lines]
add
the ORDER BY statement?
 

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

Back
Top