Field is too small to accept the amount of data...

F

FireGeek822

I have a form where I am trying to click on a button which will add
data that was entered into 2 unbound text boxes to a table.

In the following code, the error occurs at .Update. You can assume I
declared all the variables appropriately. In tblToDo, I have the Item
and SubItem fields set to 255 characters. The data in the Item box is
"Raw Data". The data in the SubItem box is "Import Actives .xls files
into DB" - Obviously neither is close to reaching 255 characters.


sql = "SELECT * FROM tblToDo " & _
"ORDER BY ToDoID"
Set rs = CurrentDb.OpenRecordset(sql)


With rs
x = ![ToDoID]
.AddNew
!ToDoID = x + 1
!ProjectID = ProjID
!Item = Item
!SubItem = SubItem
!Time = Null
!CompDate = Null
!Done = Null
.Update
.Close
End With


Any suggestions????


Tammy
 
G

Guest

Run your code in debug mode and check the length of each variable before you
update. Be sure to review the your table schema to ensure the fields are
defined correctly.

Also, you are explicitly loading Null into some fields. This is not
necessary. When you create a new record with .AddNew, all fields are set to
Null unless there is a Default Value property set for the field.
 
F

FireGeek822

Klatuu,

Thank you for your reply. I have run the code in debug mode. It bombs
out at .update. I also removed the following lines:

!Time = Null
!CompDate = Null
!Done = Null

I have reviewed each field in the table. Each is set to 255 characters
and the text being saved is only 10-25 characters long. Obviously no
where near the 255 maximum. This still bombs out at .update.

Any help still needed PLEASE!!!

Tammy
 
G

Guest

What data type is ![ToDoID]?
It should be some numeric data type. If not, it could cause a problem, but
without testing, I'm not sure what error would raise. Also, you don't really
need to use the x. It could be done as:
![ToDoID] = ![ToDoId] + 1

Another thing you might try is trimming your varialbes in case something is
going on with them you are not seeing.

lngItemLength = Len(Trim(Item))
If lngItemLength > 255 Then
MsgBox "Item is " & lngItemLength & " Maximum Allowed is 255"
End If
MsgBox "Item Length
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top