468,106 Members | 1,536 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,106 developers. It's quick & easy.

How do I update all records in table 1 by looping through table 2?

16
My application is to re-assign leads to different groups of salespeople by sequentially assigning them to each salesperson. I've got an Access 2000 front end to an MS-SQL database.

Currently, I do this effectively (but sloppily and slowly) by exporting Access records to Excel, doing my assignments there, importing back into a new work table in Access, and running an update query (joining on Lead.ID). However, I'm soon going to exceed the 64K record limitation in Excel. I'd like to accomplish the whole thing more eloquently in Access.

Let's call Table 1 LEADS, and Table 2 SALESPEOPLE.

I need to update the assigned Salesperson in the field LEADS.SP by sequencing through all records in SALESPEOPLE and looping until all selected LEADS are updated.

I used to do this in FoxPro or Dbase by opening the two tables and using syntax including "while not <eof>", "next", and "loop".

Is there a simple way to do this? I don't write VB code nor have I ever created Access Modules (though I can frequently look at existing code and modify it).

Thanks in advance for anyone's help!
Feb 2 '07 #1
3 3426
NeoPa
32,021 Expert Mod 16PB
You don't say, and I can't work out from going through the question, what you want to assign to the field LEADS.SP.
Is it a single salesperson to every lead in the table? Is it some sort of random balancing algorithm?
Feb 2 '07 #2
DWolff
16
Sorry it's been so long for me to notice your reply. . . .

The field Leads.SP is a salesperson name. I want to sequentially select each salesperson from the TABLE Salespeople, assigning the first record to the first lead, second record to the second lead, etc. When I finish sequencing through all the records in the TABLE Salespeople, it should start again from record 1 and continue sequencing until all leads are assigned.
Nov 26 '07 #3
NeoPa
32,021 Expert Mod 16PB
You will probably struggle if you don't like coding :(
What you need (I'm a SQL man mainly but can't see a way of doing this in SQL I'm afraid) is to process through the two recordsets (SALESPEOPLE & LEADS) and assign one each as you go through.
I don't know where your assignments are made (they should be in a separate table).
An example of some basic recordset processing code can be found in Basic DAO recordset loop using two recordsets.
I hope this helps.
Nov 26 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Slower Than You | last post: by
13 posts views Thread by Slower Than You | last post: by
6 posts views Thread by Suresh | last post: by
13 posts views Thread by Terry Olsen | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.