|
-
Feb 9th, 2010, 04:22 AM
#1
Thread Starter
Fanatic Member
ms access cant append all the records due to key violations
Hi,
question:
I would like to catch and handle this error (on Error doesn't catch this type of error)
How can I catch this error?
more details:
I'm running a function that inserts records into a table .
while something
mySerial = DMax("serial", "myTable") + 1
sqlstr = " INSERT INTO myTable ( serial SELECT " & mySerial & "; " )
docmd.runsql sqlstr
wend
On same cases the function halts on "ms access cant append all the records due to key violations".
Checking this further reveals that the that serial generated is already occupied - probably in the case where another user created a new record between generating mySerial to the point where actually runsql tried to commit the new record insert (?)
-
Feb 9th, 2010, 05:05 AM
#2
Re: ms access cant append all the records due to key violations
Can I see your database?
There is one more reason this error can happen...
You get this error message when you try to insert empty strings into a field that has its AllowZeroLength property set to No. Do this
1. Open your destination table in Design view.
2. Set the AllowZeroLength property of all text fields to Yes.
3. Save the changes to the table, and then close the table.
Try now...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Feb 10th, 2010, 01:58 AM
#3
Thread Starter
Fanatic Member
Re: ms access cant append all the records due to key violations
Hi,
Its a MySQL DB connected using ODBC, however the AllowZeroLength is already set to YES on all text fields.
Any ideas how to catch this error?
I would like to do something like on Error goto handleErr and there to display the problmatic record on the form and then to resume the rest of the while loop, this will be a good solution for this issue, but I cannot seem to catch the error at all.
Thanks!
-
Feb 15th, 2010, 02:42 AM
#4
Thread Starter
Fanatic Member
Re: ms access cant append all the records due to key violations
-
Feb 15th, 2010, 07:04 AM
#5
Re: ms access cant append all the records due to key violations
Why are you generating the serial yourself, rather than letting the database do it automatically (by using an Identity/AutoNumber/Serial data type) ?
That would not only take less code, but would also avoid the error and other issues with serial numbers that Identity etc deal with.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|