473,386 Members | 1,606 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,386 software developers and data experts.

How to catch error 8511 (Records unable to paste inserted into table 'Paste Errors')?

Hi all,

I'm having difficulty catching error 8511, which states:
"Records that Microsoft Office Access was unable to paste have been inserted into a new table called 'Paste Errors' In the Database window, open the new table to see the unpasted records. After you fix the problems that resulted in the paste errors, copy and paste the records from the new table."

What generally happens is people copy data from Excel and paste it over data in MS Access, but if they mismatch the columns or if some data was pasted into a combo box without a matching item in the list or a field has too much text for the back end table to accept, then it fails to update the record and gives the above message.

My goal is to rewrite the message since people are locked out from seeing the back panel with all the tables but only get a switchboard, thus making the above message meaningless. My desired error handler code is below:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Error(DataErr As Integer, Response As Integer)
  2.     Call basicErrors(DataErr, Response)
  3. End Sub
  4.  
  5. ...
  6.  
  7. Sub basicErrors(ByRef DataErr As Integer, ByRef Response As Integer)
  8.     If DataErr = 2113 Then  
  9.         Call MsgBox("The value you entered isn't valid for this field (i.e. text in numeric field)." & Chr(13) & Chr(13) & _
  10.             "To undo entry for this field, press ESC.", vbInformation, "Lists & Registers Database")
  11.         Response = acDataErrContinue
  12.     ElseIf DataErr = 2237 Then  
  13.         Call MsgBox("The text you entered isn't an item in the list." & Chr(13) & Chr(13) & _
  14.             "To undo entry for this field, press ESC.", vbInformation, "Lists & Registers Database")
  15.         Response = acDataErrContinue
  16.     ElseIf DataErr = 8511 Then  
  17.         Call MsgBox("This record could not be updated, likely due to invalid text entered into some of the drop down boxes " & Chr(13) & _
  18.             "or some of the text exceeding the maximum allowable text length for a field." & Chr(13) & Chr(13) & _
  19.             "If pasting from excel, make sure the columns in excel line up exactly with the columns in MS Access " & Chr(13) & _
  20.             "and that any data that is part of a drop down box is actually selectable from the drop down box.", vbInformation, "Lists & Registers Database")
  21.         Response = acDataErrContinue
  22.     End If
  23. End Sub
  24.  
I cannot catch it with the Form_Error event, so please let me know how to catch the error.

Thanks!
Dec 13 '10 #1

✓ answered by Lysander

Sorry jbrumbau and NeoPa not to have got back to this thread, having a little problem of my own computer:)

What I said, and NeoPa expanded upon was you can't do a mass import into Access and expect Access to handle individual record errors. You need to get the data into Access, and then validate each record one by one.

As an example, suppose your users were trying to import monthly wages from Excel into a table called tblMonthWage.

What you can do is have a button on your control panel to import the excel data into a brand new table, say tmpWage. On the code behind that button, you initiate the excel import (filetransfer I think is the command of the top of my head) and then, open a recordset based on tmpWage and loop through each record, 1 by 1.

Validate all the fields according to your own rules, such as, Is the Employee in the employee table, does the tax and NI match the gross pay, whatever validation you need to do.

Those records that pass your validation rules you write to tblMonthWage, those that fail you write to an exception table and report as errors to your user.

At the end, delete tmpWage ready for the next import.

9 5611
Lysander
344 Expert 100+
I can see what you are talking about, and the errors you are getting, but I think the error you want to trap is not trapable as it is the result of a block operation, not a record by record operation. i.e. Someone is trying to update 500 records, 3 of them fail, but you only get the error message at the end, so you don't know which of the 3 had failed.

Instead of your users updating Access tables directly from Excell, maybe you could have them import the Excel data into a clean Access table that will accept all data, and after the import has been done, go through that table record by record and update the relevant Access data, reporting one by one on each record that had incorrect format.
Dec 16 '10 #2
Sounds like quite a bit of work, I'm assuming I would have to create a separate form (i.e. EXCEL IMPORT) that has 100 generic 255 character text fields, with probably 1000 records? The user would then need to paste into it and then another button on the form would copy data from the EXCEL IMPORT form and paste it into the form of interest? I could see the potential for pasting information in the wrong columns, unless it automatically applied a column name to each column based on what form you select as the form you're trying to paste the data into.
Dec 16 '10 #3
NeoPa
32,556 Expert Mod 16PB
This is a common problem. It is basically down to the data being imported, not matching the requirements there are for that data.

The solution is to import the data directly into a table with minimum restrictions set (so that all the data imports successfully, regardless of how rubbish it is), then checking the data imported, before processing that data into your desired table. This leaves you with full control over what is allowed in, as well as how you handle any records that fail your checks.
Dec 18 '10 #4
So I'm assuming the proper approach is to link my form to an unrestricted entry dummy table, then in the form's Before_Update event is where you populate the real table?
Dec 20 '10 #5
NeoPa
32,556 Expert Mod 16PB
No. That's not right.

You need to import the data, as you say, into a dummy table, then check the data fits what you need, then copy the valid data from the dummy table to the proper table. How you handle any invalid data is up to you, but I'd suggest you let the operator know where it can be reviewed.
Dec 20 '10 #6
So I think the final answer is to associate all input controls in a form to either unbound fields or to a dummy table? Then after that, how data is handled is up to me?
Dec 20 '10 #7
NeoPa
32,556 Expert Mod 16PB
I'm not sure why you're saying what you are. I thought I was clear in what I was saying, but your responses don't seem to indicate any real appreciation of that, so maybe the best thing for you to do is to explain to me where my explanation is unclear.

This is not about creating a form to manage the dummy table. The rules for determining valid data should not depend on human intervention at all. They should be clearly defined. Your query to copy the validated records should be built to copy only the valid records, and your report (or whatever you choose to use to show the invalid records to the operator) should be designed to show the invalid ones that need attention. I can't easily imagine any scenario where a form would come into the mix for this.
Dec 21 '10 #8
Lysander
344 Expert 100+
Sorry jbrumbau and NeoPa not to have got back to this thread, having a little problem of my own computer:)

What I said, and NeoPa expanded upon was you can't do a mass import into Access and expect Access to handle individual record errors. You need to get the data into Access, and then validate each record one by one.

As an example, suppose your users were trying to import monthly wages from Excel into a table called tblMonthWage.

What you can do is have a button on your control panel to import the excel data into a brand new table, say tmpWage. On the code behind that button, you initiate the excel import (filetransfer I think is the command of the top of my head) and then, open a recordset based on tmpWage and loop through each record, 1 by 1.

Validate all the fields according to your own rules, such as, Is the Employee in the employee table, does the tax and NI match the gross pay, whatever validation you need to do.

Those records that pass your validation rules you write to tblMonthWage, those that fail you write to an exception table and report as errors to your user.

At the end, delete tmpWage ready for the next import.
Dec 24 '10 #9
Lysander,

I think your method is certainly a surefire way to get data imported from excel without any errors. As for if the user attempts to paste excel data into a form in datasheet view, I just thought of using key traps to catch ctrl+v, then when it is hit, it will use the excel data import mechanism you are suggesting and replace the key command with return or something that has no effect.

However, right mouse click with paste and using the Edit+Paste menu command in datasheet view won't be caught, I'm not sure how to catch those commands, unless the form itself is linked to a dummy table and then the data is formatted and copied over to the proper table as NeoPa is suggesting.

Thanks again for the help from both of you.
Dec 27 '10 #10

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

Similar topics

4
by: Anand Pillai | last post by:
Hi I am quite familiar with normal python errors which can be caught by using the try... except... finally clause. But very often I find other kinds of exceptions raised in my programs. Here...
4
by: Scott Kinney | last post by:
I have an inventory database. I want to delete out-of-stock items from the main database, but keep them in a separate table so that I can reference data about them. I created a copy of the item...
28
by: Lee Rouse | last post by:
Hello all, This is going to be a rather lengthy "question". I have an Access 2k database, separated front end/back end. Front end copies are on about 30 workstations and used frequently during...
0
by: crypto_solid via AccessMonster.com | last post by:
I have been using a SQL database with a VB5 frontend for about 5 years. Works well. Unfortunately I don't have access to the source code. I was tasked with implementing a "job entry" application...
16
by: Ian Davies | last post by:
Hello Needing help with a suitable solution. I have extracted records into a table under three columns 'category', 'comment' and share (the category column also holds the index no of the record...
4
by: sparks | last post by:
I am trying to fix a database that someone did about 4 yrs ago in access97. The main table just contains demographics and is on the main form of the database. It has a subform on a tab that...
3
by: Dave | last post by:
I'm writing a c# Windows program that needs to be able to insert records into a dbase table. I can read it using a dataset but can't insert records. I receive the following error, ERROR ...
3
by: svgeorge | last post by:
Please tell me how to Insert Web Interface records to SQL database table on Button click I have several records for approving payment and these records needs to be inserted into a table Payment...
6
by: knkk | last post by:
I recently migrated to PHP 5.3.2, and realized that I am unable to turn off notice errors in my site now. I went to php.ini, and in these lines: ; Common Values: ; E_ALL & ~E_NOTICE (Show...
0
by: krisssgopi | last post by:
Hi Team, While am using the below code it was throwing an exception update unable to find table mapping or data table customer. Please help me in this regard. Private Sub Button1_Click(ByVal...
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
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.