473,385 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Why am I getting a key violation when appending records?

Hi,
I am currently getting a very odd key violation when appending values to a table. The strangest thing is that it is only happening some of the time.

I have a form where people can create schedules. They can create single day events or they can select events that happen every Tuesday from today until the last day of September for example. Their schedule gets parked into a temporary table where they can then edit any details (for deleting bank holiday dates, etc.,) and they then click a button to append the data to the schedule table.

When I do single-day events they append fine, but with the multiple dates I am having some problems and can't work out why. This is because there seems to be no rhyme and reason. When I select dates that are on the same dates as ones already in the schedule table I sometimes get a 'key violation' error. This only happens sometimes. For instance I just chose 10 different dates to append, all which were already featured in the schedules table and only one had a key violation. I then tried adding the same dates again with different data and all 10 had key violations.

In the schedules table the primary key is an autonumber. I have set the 'dates' field as Indexed Yes (Duplicates Ok) and made sure that all other fields are either not indexed or specify Duplicates Ok.

Can anyone think what this problem could be? I am really at a loss at the moment. I keep testing to try and find the problem but just can't work out why exactly this error is coming up.

Thanks!
Russ
Aug 26 '10 #1
5 1801
I can now definitely say that it is a problem with the 'dates' field. I have changed the append query so that the only fields being appended are the 'date' field and one other and each time there is a key violation. If I append all data except for the 'date' field it appends file and if I only append the 'date' field it works fine, but as soon as I try and append the 'date' field along with any other field, be it a number, text or memo it has a problem.

What the devil is going on? Has anyone experienced anything like this before?
Aug 26 '10 #2
NeoPa
32,556 Expert Mod 16PB
Russ Slater:
In the schedules table the primary key is an autonumber. I have set the 'dates' field as Indexed Yes (Duplicates Ok) and made sure that all other fields are either not indexed or specify Duplicates Ok.
I must admit, I was confident it was an index or relationship issue until this bit.

I'm sorry to doubt you, but could you double check the indexes, and perhaps also look at the Relationships window to see if anything is set up there that may be relevant.

Welcome to Bytes!
Aug 26 '10 #3
I've double checked the Relationships. There is nothing there. I've never even got to the point of creating any relationships yet so that's not too surprising really.

Checked all the indexes too. They are all 'no' or 'Yes (Duplicates OK)'. What's the recommended status for these. Is it best to index them or better that they are all set as 'No'?
Aug 26 '10 #4
It now seems to be working fine. I deleted all the records in all the tables I had been working with, and hey presto, it was working after that.

I'm not sure I'll ever understand Microsoft Access!
Aug 26 '10 #5
NeoPa
32,556 Expert Mod 16PB
Well Russ, indexing is about various issues, but foremost among these is the ability to find or link records by a particular field or set of fields. The uniqueness is dependent simply on whether or not the field could validly hold the same value more than once. A PK should always be unique as it is the principle identifier for the record. An example would be a Product Code field for a Product table. Only one Product in the table could ever have any specific value. Two products with the same Product Code wouldn't make sense.

A Product Group field, on the other hand, may require a non-unique index. Reporting on products by Product Group would be greatly helped by such index, but making it unique would mean only one product could belong to any group. Not a good plan.

I'm glad your problem got resolved anyway. I've little idea what may have caused it but it may have been related to corrupt or invalid data already in the table.
Aug 26 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: dixie | last post by:
If I have two compatible tables, but in two separate databases, can I append the records in one table onto the records in the other by code in either a module or a form. If the two databases were...
7
by: PC Datasheet | last post by:
Looking for suggestions ---- A database was designed for a national automobile inspection program. In it's simplest form, the database has two tables: TblOwner OwnerID <Year/Make/Model owned...
4
by: Matt Sawyer | last post by:
I am attempting to use an API (CxApiOem.dll) that has a large number of defines and complicated structs. It's just too much hassle to attempt to use DLLImport to make the desired API calls. ...
1
by: dipesh | last post by:
I am getting error when trying to Add Web Reference in Visual Studio 2005. "Some of the files required for web references are not installed"
0
by: RKT | last post by:
I have a DataGridView bound to an MS Access table. This is a single- user application. When the User is adding or editing a row, the User may click on a Control elsewhere. That Control has context...
1
by: jonny | last post by:
Went from using Visual Web Develop express to Visual Studio 2005 and getting error when trying to open project. Error message: "One or more projects in the solution could not be loaded for the...
7
by: Dev1 | last post by:
All- I have two tables, A(Company) and B(Owner). I want to import the excel sheet into a temp table. Second I want to write two append queries that will append records to the company table and...
0
by: =?Utf-8?B?UmF2aQ==?= | last post by:
Hi, I have WCF service and integrated with STS (WS-Federation). The Service exposes 5 endpoints Win, UNT and Federated Windows, Federated UNT and Mex endpoint. My STS Service exposes 3 endpoints...
3
by: shwethatj | last post by:
Can anyone help me please .... My vb.net application is getting closed when i trying to run the solution ... What might be the problem ... Am new to .net .. Regards, Shwetha
4
by: sumit kale | last post by:
Hi, Can somebody help me resolve my problem ? I am getting error when calculating total using unbound textfiled in subform. I have a main form called purchase_register_master and a subform...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.