Access 2007 save record to two tables with some logic

I have two tables for tracking serialized parts.  Table A has customer information, part information, and serial number.  Table B has the date, location, and serial number.  Receiving uses an Access 2007 form to collect the date, customer, customer PO, sales order, type, assembly number, and serial number.  When the record is saved all the collected info saved to Table A.  Also when the record is saved I need a record added in Table B the date, serial number, and location.  I need the location to be determined by the customer name collected.  So if the customer name is John then the location would be Stockroom.  If the customer name is Susan the location would be Assembly.

Thanks,
Brooks

Thanks,
Brooks
gbnortonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
how many customer do you have? if there are multiple customers, create a mapping table for location according to customers..

is the form they are using to collect information bound to the table?
0
gbnortonAuthor Commented:
3 customers.

yes, it is currently bound to Table A.
0
Rey Obrero (Capricorn1)Commented:

with currentdb.openrecordset("TableB")
      .addnew
      ![date]=date()
      ![serial number]=me.[serial number]
      !location=switch(me.customer="John","Stockroom",me.customer="Susan","Assembly",me.customer="Other","OtherLocation")
      .update
end with

0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

gbnortonAuthor Commented:
Regarding where that code goes and implementing it, I have a module called Functions.  Do I put it there?  How is it called?
0
Rey Obrero (Capricorn1)Commented:
you can place the codes in the afterupdate of the form

private sub form_afterupdate()

with currentdb.openrecordset("TableB")
      .addnew
      ![date]=date()
      ![serial number]=me.[serial number]
      !location=switch(me.customer="John","Stockroom",me.customer="Susan","Assembly",me.customer="Other","OtherLocation")
      .update
end with
end sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gbnortonAuthor Commented:
Works perfect.  Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.