Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

field size too small???

Status
Not open for further replies.

A10Instructor

Technical User
Feb 7, 2005
27
US
I have a form with 15 text/combo boxes. In one combo box, every time I select the longest selection (70 characters), it displays all characters but a message box appears.

The message box states "The field size is too small to accept the amount of data you attempted to add. Try inserting or pasting less data."

The field size in the table is set to 255 and is correct. I have another form with far fewer boxes and do not encounter this problem.

Any help would be appreciated as to what is happening and a possible fix.

Thanks





A10 Instructor
"The World is My Classroom
 
The field size is too small to accept the amount of data you attempted to add
The error message suggests that text box on the control is receiving too much info for the field. "Field" will refer to the field on the table.

I do not think this refers to having too many controls on the form.

You can test the length of the text before the update by using BeforeUpdate event procedure.

Debug.Print Len(Me.NameOfYourTextBox)

Then use CTRL-G to view the debug / immediate window and look at the number printed.

If it is larger than 255, then you know that more than 255 characters was entered into the text field.

If the number is less than 255, then check the field on the table in design mode.

Richard
 
Good point Geoff. Then A10 can consider using the Trim function.
 
willir,

Thanks for the tip. I'm new to the debugger option and seem to have a hard time to get it to work. It is a combo box in which I get this error.

Do I place the debug line in the beforeuipdate of the form itself or the combo box? Then how do I work the deguigger tool to get it to display the number?

Thanks

A10 Instructor
"The World is My Classroom
 
I don't know what if any code you have tied to your forms.

Preamble:
For open in design mode and "Properties" window is open. (From the menu, "View" -> "Properties")

Click on the control in question (Control = text, list or combo box plus other stuff such as check box, option groups, etc)

Look at the "Other" tab in the "Properties" window, and note the value in the "Name" field -- this is the name of the control -- make note of the name; you will need to use later. If the form was created using a wizard based on a table or query, the "Name" will be same as the field on the table the control is "bound" to.

Now click on the "Event" tab of the "Properties" window. Select the field adjacent to "BeforeUpdate", select "EventProcedure" from the drop-down box, and then click on the "..." command button that appeared to the right when the field was selected. This will take you to the VBA coding window, and create two lines of code...

Code:
Private Sub NameOfControl_BeforeUpdate(Cancel As Integer)

End Sub

Assuming the following...
YourControl - Name of your control on the form (text, list or control box)

Code:
Private Sub [COLOR=blue]YourControl[/color]_BeforeUpdate(Cancel As Integer)

Debug.Print Len(Me.[COLOR=blue]YourControl[/color])

End Sub

If you have any other code in the BeforeUpdate, the Debug line can go anywhere as long it is not in an If/End If or SELECT Case statement. Near the top may be the best.

Of course, you will have to be substituted by the "Name" of the control you determined in the "Properties" window with the YourControl.

Richard
 
Willir,

Thanks for the quick response and all of the help. I finally did get the debug to work. Typos will get you every time!

I also found the cause of my problem. I had the size of the final destination table field set smaller than the field in the look up table.

Again, thanks for al of the help.

A10 Instructor
"The World is My Classroom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top