Results 1 to 8 of 8
  1. #1
    lizzywu is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    41

    Update some fields by appending query

    Hi there,



    I'm trying to append my active address information from table1 called taddress (which contains customer_id) to the corresponding fields in table2 called tcustomer to update address information in tcustomer. The fields have the same data type.

    When I tried to append the new activated values from taddress to the corresponding fields in tcustomer, a dialog about type conversion failure prevented me from appending.

    Is there any way to make such appending perform successfully?

    I attach my files here. Could you help me check?

    Thank you very much!

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Are you wanting to add the records from taddress to the table tcustomer? Or do you want to update the existing address for each customerid on tcustomer?

    If you are trying to add new records to tcustomer then each record will need a unique primary key, the link_id. Your query does not address that field and it is not an autonumber field so needs to be populated manually using your query. I tried running your query a number of different ways and each time got a different message - I don't think Access knows what to do!

  3. #3
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Also your postal code field is text in one table and number in the other. This may also cause problems.

  4. #4
    lizzywu is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    41
    Aytee111, I actually want to replace the old address in tcustomer with the new address in taddress. So it's not adding new records but updating the old records. But if I use update query, it won't allow me to replace the whole column.

    Also, even after I change the data type of postal code field into number, the same dialog pops up.

    I attach the modified one here. Could you help me check again? Thanks a lot.

  5. #5
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Append queries adds new records to a table - update queries update existing ones. You definitely do NOT want an append query, but must get the Update one to work correctly. I don't understand what you mean when you say it won't let you update the whole column?

    I would rather you learn to do it than me do it for you. Lesson 1: do a select query first, then afterwards we can change it to an update query. So send me the SQL of a query that displays all the fields you are using, both the new addresses and the old, all in one query.

    On a database design note: are you sure you want to remove the old addresses? You don't need to keep them for past reference purposes?

  6. #6
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Another design question - why are you keeping the address more than once in the database? This breaks rules of "normalization" where data is kept only once in a database and is linked to via queries when needed.

  7. #7
    lizzywu is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    41
    Thank you.

    I want to remove the old addresses in tcustomer, and the old addresses are kept in taddress. When there is any new address coming for a specific customer, I add it into taddress and make it active and I also deactivate the old addresses.

    Here's what I did:
    UPDATE tcustomer INNER JOIN taddress ON tcustomer.customer_id = taddress.customer_id SET tcustomer.addr = [taddress].[address], tcustomer.addr_city = [taddress].[city], tcustomer.addr_state = [taddress].[state], tcustomer.addr_postal_code = [taddress].[postal_code]
    WHERE (((taddress.active_addr)=Yes));

    It works!

    Thank you so much!

  8. #8
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Well done - you've come a long way!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. update multiple fields
    By slimjen in forum Queries
    Replies: 4
    Last Post: 01-27-2012, 10:12 AM
  2. UPDATE query with many fields
    By Deutz in forum Queries
    Replies: 7
    Last Post: 08-23-2011, 05:53 PM
  3. How to update fields automatically
    By kosan in forum Forms
    Replies: 1
    Last Post: 09-10-2010, 04:49 PM
  4. Replies: 5
    Last Post: 03-20-2010, 08:30 AM
  5. Use combo box to update other fields
    By Shep in forum Access
    Replies: 7
    Last Post: 07-23-2009, 03:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums