How to append records to a table that already has those records...

Triedtwice

New Member
Joined
Feb 17, 2014
Messages
31
I can't seem to make an Append Query do what I want...any help will be appreciated!

I need to append records to a table called "tbl_6A_POP" from a table called "tbl_Media_Code". tbl_Media_Code has 7 records ("1000" thu "6000" plus "6500" in a field called "Media_Code"). tbl_6A_POP already has a field called "Media_Code" that has several hundred entries...an excerpt from tbl_6A_POP looks like this:

MC_PKTTLM_No_PKMedia_Code Rec_No
335242300019-39-5
3362423000749-9-1
337242400056-55-378
338242400050-3-8
339242400020-9-2
340242400053-704-3
341242400013-9-5
34324450001479-73-001
344244500079-1-634
3482476000NA_None
3492486000NA_None
3502496000NA_None

<tbody>
</tbody>

As you can see, there are multiple records for a given TTLM_No_PK, but not every Media_Code is recorded for each TTLM_No_PK. I need to append tbl_6A_POP to have each of the 7 records from tbl_Media_Code for each TTLM_No_PK in tbl_6A_POP. Even as I'm typing this, I realize I'm probably not making any sense...but if you might have a suggestion for getting the missing "Media_Code" records into the tbl_6A_POP table WITHOUT deleting the existing Media_Code records in tbl_6A_POP, I'll be a happy camper!

Thanks!
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
You are right - it is not making much sense.

First, understand the different types of Action Query types, and choose the appropriate one(s) for your task at hand:
- Make Table Query - this creates a brand new table and adds records to it
- Append Query - this only ADDS records to an existing table
- Update Query - this only UPDATES existing records in another existing table
- Delete Query - this will DELETE records from an existing query

When creating an Append Query, here is the way I usually go about it.
- First create a Select Query that contains JUST the records you want to append to the other Table
- Once you have that first part working right, change the Query to an Append Query, and make sure that you have all the correct fields being mapped to the right place.
- Run the query

So, which part is giving you issues?
 
Upvote 0
Thanks for the prompt reply!!! I'll try to better explain what I need. I'm trying to append the table "tbl_6A_POP" to show each of the 7 media_codes from the "tbl_Media_Code" table...but tbl_6A_POP already has data for some of the media_codes that I don't want to overwrite with the append query. For instance, the current records from tbl_6A_POP for a single TTLM_No_PK looks like this:

IDTTLM_No_PKMedia_CodeRec_No
335242300019-39-5
3362423000749-9-1
337242400056-55-378
338242400050-3-8
339242400020-9-2

<colgroup><col><col><col><col></colgroup><tbody>
</tbody>

I need it to look like this:
IDTTLM_No_PKMedia_CodeRec_No
3352421000NA_None
3352422000NA_None
335242300019-39-5
3362423000749-9-1
337242400056-55-378
338242400050-3-8
339242400020-9-2
(auto)2425000NA_None
(auto)2426000NA_None
(auto)2426500NA_None

<colgroup><col><col><col><col></colgroup><tbody>
</tbody>

the Media_Code values of 1000, 2000, 5000, 6000, and 6500 were added, each with a value of "NA_None" for the field Rec_No.

Man, I'm doubting that I'm making any more sense...but maybe?
 
Upvote 0
I don't want to overwrite with the append query.
Append queries never overwrite data - they only add new records.
Update queries are the ones that would update (or overwrite) existing records.

So if you are using an Append query, you would not have to worry about any data being overwritten.
 
Upvote 0
so...is it possible to get the 7 different records from tbl_Media_Code into each TTLM_No_PK from tbl_6A_POP?
 
Upvote 0
I think it is possible using VBA. Couple of questions first: is ID unique, second is ID an autonumber (slightly redundant question),
what is the volume of records? in the main table?

Jack
 
Upvote 0
Remember what I said back in the first post?
When creating an Append Query, here is the way I usually go about it.
- First create a Select Query that contains JUST the records you want to append to the other Table
So, your first step is to just create a Select Query that has the records you want to write to your table.
If some of the records already exist, you should be able to create an Unmatched Query to return just the records that do NOT already exist (there is even an Unmatched Query Wizard).
So create that first, then change to an Append Query, and it should add just the records that you want.
 
Upvote 0
Thanks! I'll give that a try (never tried an Unmatched Query)!
Its always a good idea to make a backup/copy of your database. That way you can feel free to play around with it, and if you mess anything up, you can restore the copy.

One caveat on the Unmatched Query Wizard is that the Wizard only lets you join on one single field. If you need more than one field in your join, just go through the Wizard and set it up to join on one field. Then when finished, open the query in the Query Builder and add any other joins that you need (making sure that the go in the same order as original one, as you will be using Left Joins). After you click on one field and drag to the field in the other table to create the join, if you click on the join line, it will let you change the join type so that it matches the first (they should both have arrows pointing in the same direction if done properly).
 
Upvote 0

Forum statistics

Threads
1,215,358
Messages
6,124,487
Members
449,165
Latest member
ChipDude83

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top