|
-
Aug 24th, 2000, 11:26 AM
#1
Thread Starter
Frenzied Member
How do you limit the length of text the user enteres into a row in a dbgrid?
The problem I'm having is that the particular field that a column in the dbgrid is attached to in my database has a length of 50. If the user enteres more than that in the dbgrid, is just says "Errors Occured". What I want to do is simply prevent the user from entering more than 50 characters so that when the user hits 50, it simply does not allow him to type any more characters..
Any help would be appreciated..
dan
-
Aug 24th, 2000, 11:37 AM
#2
Frenzied Member
In the keypress event, check the length of the field. If it's larger than 50, pop an error message.
if len(dbgrid.text) > 50 then
dbgrid.text = left(dbgrid.text,50)
msgbox "the field cannot contain more than 50 characters"
end if
_OR_
if len(dbgrid.text) > 50 then
KeyAscii = 0 ' invalidate the last keystroke (although you should check for a backspace
msgbox "the field cannot contain more than 50 characters"
end if
[Edited by JHausmann on 08-24-2000 at 12:41 PM]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|