Update table

  • Thread starter samotek via AccessMonster.com
  • Start date
S

samotek via AccessMonster.com

I want to build a function that deletes all the records in the field B of the
table customers and copy all the records from field A into field B.Could you
help me ? The table Customers has an autonumber field called Customerid
 
J

John Spencer

You want to set fieldB of a record to the value in field A of that record.
Then what do you want to do with field A - set it to null (blank) or leave
it as is?

--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
S

samotek via AccessMonster.com

John said:
You want to set fieldB of a record to the value in field A of that record.
Then what do you want to do with field A - set it to null (blank) or leave
it as is?

Thank you for your reply.I want to leave the field A as it is. However after
i suceed in making the field B equal to the field A, i wanrt to update that
field and place the letter BD at the beginning.Fir example if the field B for
customer 1 is 8888455, i want to update it and make it CD8888455

kind regards
 
J

John Spencer

UPDATE YourTable
Set [Field B] = "CD" & [Field A]
WHERE [Field A] is not null

In the query grid
-- Add Field B to the grid
-- Select Query: Update from the menu
-- Enter "CD" & [Field A] into the Update To "cell"
-- Add Field A to the list
-- Enter Is Not Null as the criteria for Field A
-- Select Query: Run from the menu

That said, WHY are you doing this. It makes no sense to store the same data
twice in the table. You are just asking for the data to get out of
synchronization if you add a records or modify field A.

You can always add "CD" to field A in a query when you need the values in
Field A preceded by the letters "CD" Or "BD" - whichever is correct.

--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

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

Top