I am trying to update a field (CustID)in a table (customers). There are no primary keys defined. I have a lookup table called lookup, which contains two fields, group and prefix. The prefix is the first letter of customers lastname in the table customers. The group is a number code for the prefix, a, b, c =1, d, e, f= 2 and so on up z which is 9
What Iam trying to do is to take the first letter of the surname and assign a customer ID. So if for example a customers surname is Adam, the customer ID is 1001, and if I add a second customer whos surename begins with A, the ID would be 1002. For names begining with B, ID would read 2001, 2002 and so on.
When I try to update, I get a message saying that 'operation must use an updateable query'.
Here is the quey that I am trying to use.
UPDATE Customers SET Customers.CustID = 1+(select max(customers.[CustID])
from table1, lookup
where left(customers.[last name],1)=lookup.[prefix]
and lookup.[group] =(abs(customers.[custID]/1000)))
WHERE Customers.[CustID] In (Null," ");
What am I doing wrong?
What Iam trying to do is to take the first letter of the surname and assign a customer ID. So if for example a customers surname is Adam, the customer ID is 1001, and if I add a second customer whos surename begins with A, the ID would be 1002. For names begining with B, ID would read 2001, 2002 and so on.
When I try to update, I get a message saying that 'operation must use an updateable query'.
Here is the quey that I am trying to use.
UPDATE Customers SET Customers.CustID = 1+(select max(customers.[CustID])
from table1, lookup
where left(customers.[last name],1)=lookup.[prefix]
and lookup.[group] =(abs(customers.[custID]/1000)))
WHERE Customers.[CustID] In (Null," ");
What am I doing wrong?