Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Index or Primary Key contains a null value 3

Status
Not open for further replies.

KadiDancer

Programmer
Jun 12, 2001
5
US
Ok...

I am trying to cut and paste a bunch of new information (ID#, Fiscal Year, Location, Event and Date) into a huge table entiteld ATTENDANCE (a list of people in our database and where and when they have seen a concert)

For some reason, every time I try to paste a list (ie: date attended) into the table ATTENDANCE, the PC says "Index or Primary Key cannot contain a null Value" and then proceedes to paste everything into a paste errors table. The only way I can paste anything into this attendance table is if I do it one record at a time (I have 2000 new records!!!)
Can anyone help? Thank you THank you Thank you....
 
use an append query.

Cut and Paste is VERRRRRRRRRRRRRy BAAAAAAAAAAAAAADDDDDDDDD.

You can do an append query from the query grid design tool which is part of Ms. Access.


MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Why isit so bad? I am a little new to this, so I need all the help IO can get.

So just do append query. Thanks a bunch!
 
IO can't tak much time for this, but I'll TRY to get you started.

With the database Window having the focus.Click on "Queries". then Click on "New" (Two Grids with a "Star" and word "New")

This 'starts' a dialog box. Select (actually, this is the default, so it SHOULD already be selected) "Design View" (top choice in the list), then Click the "O.K." button.

The dialog closes and a BLANK query grid pops up with the recordsource selection (Select Table) dialog box in the foreground.

From the lists, select the table/query/recordsource(s) where the data fields currnetly are. You can add multiple tables and or queries to the new query either by clicking each source and then the "add" button, or double-clicking each source. If you select multiple sources, the process will get more complicated than I have time for today (thinggs like "Joins" and / or sub-queries). Assuming that you are doing a single recordsource, select it, add it to the query grid and CLOSE the dialog box.

You should see a divided grid thinngyyyyy. The upper part has a grey background with the recordsource 'setting' on it. This has an asterisk "*" in the top row and each of the field names below in a scrollable list. You must select each field you want to copy from the recordsource to your table. You can/may select the items in several manners.

Select any one field name. Select any additional field names holding down the "Control" key (must select each, one at a time). Select any (already selected) field and WHILE HOLDING DOWN THE MOUSE BUTTOM drag the "field(s)" to the top row of the grid thinggy below. Boom! all of the selected fields appear in the top row of the grid. Each in its own column.

Alternative. Double cllick each desitred field. Boom each field selected/double clicked is added to the top row of the next column of the grid.

Another way. If the desired fields are 'contigious", select the first (topmost) in hte list. Find the last (bottommost in the list). Hold down the SHIFT key and select the Last. Cllick (AND HOLD) on any of the selected and drag it to the top row of the grid. Boom!! all of the fields appear in the top row of the grid, each in a seperate column.

WhEEEEEEEEEEE
These (in almost any combination) should get the fields of the soutrce in the top row of the grid. If you have 'accidently' added something extra/ectraneous, delete "it" by selecting the field (column) in the grid and pressing the "Delete" key (on the KeyBoard). You do the selection by getting a BOLD down arrow to appear as the "cursor". BY moving the 'whatever' cursor tot he VERY TOP of the grid column.

Double Whew WOW!!

Look at the "Menu Bar" (top of hte access window. Find the "Query" meny. Click on it. Drop down menu. "Green Cross" ("Append"). Click on this. Dialog box appears. Select the destination table from the Combo box" Click the "O.K." button. The grid part of the query changes to include a new ROW, "Append to". Hopefully, htis "row" is also populated with field names.
We SHOULD be done! BUT .....

If the "recordsource" and the destination have the SAME field names, the destination field names, the append row will show the fields which will be populated in the records to be added to the "big" table. If ANY "Append to" cell is NOT FILLED in, you will need to fill it in. The "Append to" row consist of combo boxes witht he field names of the DESTINATION table, so you just select them. The only issue I see from your earlier discription is the Primary Key field(s) of the destination data base MUST be included in the field(s) being appended - - - UNLESS - - - they are Auto generated fields (AutoNumber of GUID), in which Case they MUST NOT be included in the append.

ASSUMING (Another UGLY word) trhat all is "well" - SO FAR, you might be tempted to procede. DON'T - YET.

You mentioned that you were "copying" and (UGLY UGLY UGLY) "pasting" records from the recordsource to the destination. If you were copying ALL of the records, you can proceeds, otherwise, you NEED to set up the query to select the correct sub-set of the records.

If you need to select sub-set(s) of the recordsource, it is done with the criteria row. Basically, the question is ~~~:

"Where ... SomeField ... (meets) ThisCriteria"

So when you know HOW you selected the records in the Cut and Paste operation, you know what the criteria was / is.

For exmple if trhe recordsource has a field "MyName" and you wanted all of the records where [MyName] started with "c", the Criteria Row in the [MyName] Column would look like"

[tab]Like "A"*

There are WAY to many variation (permutations and combinations) of this for me to even START, so I'm hoping that you were just doing all of the records. If so, you can JUST click on the execute button on the Query design tool bas (it is te "Exclimination Symbol ("[red]![/red]") in red). Ms. Access will give you some message box(es) describing the results and one telling you how many records were added - and if any are NOT - which were selected to Add, 'why' they weren't.

If you need help with the "criteria", Hopefully someone will provide it. You can also use the HELP system in Ms. Access. It can be useful.

I will not be "on-line" for a while, so If this doesn;t suit you, you either need someone else - or have patience - and respond with SPECIFICS of what is not clear or what errors/problems you have.


MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Just for going through the effort of walking her through at that level, I gave you a star...

;-) Terry M. Hoey
th3856@txmail.sbc.com
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.
 
I second that Terry. Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top