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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limit character typed into textbox - SQL backend

Status
Not open for further replies.

BMarkham

Programmer
Apr 30, 2001
14
US
I think I'm out of luck, but I'll ask anyways.

When the record source of a form is an Access table, a textbox will automatically limit the maximum number of characters that can be typed into to the field size of the text field it's bound to.

I'm using Access 2k and SQL server 2k. The record source for my Access form is an attached SQL server table. When viewing the design of the attached table in Access, it shows me the correct data types and sizes. However, it doesn't limit the characters I can type in the text fields. This is obviously a problem as I could unknowingly and accidentally type too many characters and when it tries to save the record, I get an ODBC call fail.

Is there an easy way to limit the characters that can be entered into the textbox? Like is there a property I've just overlooked? Or am I going to have to code it to check the length of the values before the record is saved.

Thanks in advance,
Brett
 
There's no property that I know of that limits the number of characters. You could use the Len() function in an event and warn the user that characters will be truncated. If they say ok, you could use the Left() function to limit the length of the string so you don't get the ODBC error. It sounds like you already have an idea how to handle this, but I thought that I'd throw this out for your consideration.

Best,

dz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top