The field is too small to accept the amount of data you are attempted to add

Katana24 picture Katana24 · Aug 9, 2013 · Viewed 8.9k times · Source

I was just handed a query to add to a macro which simply adds to a table called exceptions based on a certain criteria; however I'm getting the above error.

I have read the Microsoft Support entry regarding this error and it refers to the use of the Memo datatype in one of the fields; none of the tables used have such a field, they are either Text or Number. Here is the query:

INSERT INTO Exceptions ( [Unique Number])
    SELECT qryOutgoings.[Unique Number], 
    FROM qryOutgoings LEFT JOIN tblExlcusions ON qryOutgoings.[PLAN CODES] = tblExlcusions.[PLAN CODES]
    WHERE (((tblExlcusions.[PLAN CODES]) Is Null));

(Note: Yes i have changed the fields and query names for security, just in case :) )

The datatype of the Unique number in the Exceptions table is:

  • Text
  • Field Size: 50

Its datatype from the other table (gotten through a join on the qryOutgoings) is EXACTLY the same. So what is causing the issue?

Here is a sample of some of the data in that field, including the largest number:

  • 515145
  • 132132
  • 824
  • 772794

What could be the problem here? Also - note this is JUST MS ACCESS - there is no SQL Server background involved.

Answer

HansUp picture HansUp · Aug 9, 2013

The SELECT clause includes a single field followed by a comma.

SELECT qryOutgoings.[Unique Number],

If that comma is also present in the actual query, discard it. However I suspect that stray comma is in the question but not the actual query because otherwise you would get a different error message.

Try explicitly casting qryOutgoings.[Unique Number] as string.

INSERT INTO Exceptions ([Unique Number])
    SELECT CStr(qryOutgoings.[Unique Number]) 
    FROM qryOutgoings LEFT JOIN tblExlcusions ON qryOutgoings.[PLAN CODES] = tblExlcusions.[PLAN CODES]
    WHERE (((tblExlcusions.[PLAN CODES]) Is Null));

If that doesn't eliminate the error, examine what Access sees as the data type of that field, and the length of the text it contains.

SELECT
    qryOutgoings.[Unique Number], 
    TypeName(qryOutgoings.[Unique Number]) AS type_of_unique_number, 
    Len(qryOutgoings.[Unique Number]) AS length_of_unique_number
FROM
    qryOutgoings
    LEFT JOIN tblExlcusions
    ON qryOutgoings.[PLAN CODES] = tblExlcusions.[PLAN CODES]
WHERE (((tblExlcusions.[PLAN CODES]) Is Null));

If nothing else solves this, try asking for the left-most 50 characters.

SELECT Left(qryOutgoings.[Unique Number], 50)