Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 15th, 2005, 10:59 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default Append Query Quandry

Here's a new problem I've never encountered.

I have a button on an unbound form that simply appends a new record to a table (via an append query) that's not connected to the form at all. I keep getting an error message from the append query that the record cannot be added to the table due to key violations. The field that is restricted is the primary key. It is the autonumber field called lngRecNo. My query does NOT try to assign a value to this field at all because it will be generated on its own. The query does fill the other fields which have no restrictions.

Why would I get a key violation error when the autonumber primary key should be filling in on its own and Access would not violate its own rules when creating a new number? Any ideas?

I'm using Access XP (2002). Thanks in advance.
__________________
Greg Serrano
Michigan Dept. of Environmental Quality
Air Quality Division
 
Old November 15th, 2005, 11:06 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Greg,

I've run into this before. Even though you have no restrictions on the other fields in the table, are any of those other fields related to another table? If they are, and you have the cascade update/delete property set on the relationship, it won't allow you to add a record.

Kevin

dartcoach
 
Old November 15th, 2005, 04:57 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Kevin, negative on both counts. The query is in the front end database and the table is on the back end (i.e. split dB). It's a very simple append query.



Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old November 15th, 2005, 05:16 PM
Authorized User
 
Join Date: Oct 2005
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Figgis
Default

Greg,

The only times I have come across this sort of error are when as Kevin states there is a relationship that causes a violation of data integrity or when I inadvertently tried to append the wrong fields. Unfortunately Access doesn't always give you a good explanation on the error. The last occasion this occurred for me was due to exactly what Kevin has described. I too have my database split but on the table end there was a relationship that had been created to facilitate a cascading delete. If your sure there are no relationships tripping you up then it has to be the data your appending or the fields your appending to. I think I would set up a select query based on you original criterea and examine the results. If all seems fine then I would export it to a spread sheet then manually pull that back into the tables. If that all works then I would say its something to do with the formulation of your append query. Not a very presise answer i know. Hope that it helps though.


Jim
 
Old November 15th, 2005, 05:45 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

OK... solved but definitely put this on the "Wall of Weird" as Chloe Sullivan would put it.

The autonumbering system in Access was violating itself. So I opened the backend dB and made a copy of the table. I delete all records in the original table. I compacted and repaired the database. I put back all the records in the table. The autonumbering started back up with the number 1 to 899. I closed the BE.

I opened the FE and now it is working as it should. Records can now be added to the BE because I reset the autonumbering. Weird, huh? That has never happened to me before.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old November 15th, 2005, 06:36 PM
Authorized User
 
Join Date: Oct 2005
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Figgis
Default

very odd. Sounds like a corrupted relationship but I haven't come across that before.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Append Query bright_mulenga Access 1 January 3rd, 2007 01:33 PM
Append Query Cybersurfer Access 1 February 13th, 2006 01:02 PM
append query? bph Access 2 November 23rd, 2004 12:44 PM
Query Quandry Ben Access 2 February 10th, 2004 06:30 AM
append query stoneman Access 2 November 12th, 2003 09:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.