Update Query

B

Bookmdano

I need to add an Account Title field to a database and I'm not sure how. The
account title would be based on the Account Number. So it would be something
like if account number is 001 then account title = Cash. If account number is
002 then account title = deposits.

Any suggestions? thanks!
 
N

NetworkTrade

first add the new field to the table

then it depends on how you want to populate that new field

you may indeed want a one time query with an iif statement to create the
data in order to apply to existing records if you are not familiar with
iif statement - search on it in this site you will find lots of examples

at the same time you might want to add this new field to a form so it gets
entered as data gets entered for new records being made
 
P

pietlinden

I need to add an Account Title field to a database and I'm not sure how. The
account title would be based on the Account Number.  So it would be something
like if account number is 001 then account title = Cash. If account number is
002 then account title = deposits.

Any suggestions?  thanks!

Create a table of
(AccountNumber, AccountTitle)

If AccountNumber is just a prefix (first n characters of the field),
you could use a theta join instead of an inner join.

INNER JOIN:

SELECT t1.AccountNo, t2.AcountTitle,...
FROM t1 INNER JOIN t2 ON LEFT(t1.AccountNo,3)=t2.AccountPrefix
...
 
Top