>Ok, here is one for ya (VFP6 SP5):
>
>I've been asked to not only impose a limit on the number of typed characters in a combobox (style 0), but to also halt the ability to type any more after the limit is reached. Since comboboxes don't have a MaxLength, I'm using the InputMask, and setting CONFIRM appropriately in the When and Valid so they don't leave the field. No big deal. The issue comes with the fact that after the limit is reached, the users
can keep typing, overwriting the last character. (I've also noticed that this occurs in textboxes as well.)
>
>Is there a property or setting I'm missing that prevents this? Or does this have to be coded in the InteractiveChange/Keypress?
>
>I'm trying to avoid being hit with the "Access doesn't do that" statement...
>
>Thanks,
>
>- Brian
Hi Brian,
I have Input Classes in Download section here. It's not exactly, what you're asking, but you can borrow the idea.
Here is KeyPress event of my composite class:
lparameters nKeyCode, nShiftAltCtrl
local lcValue
lcValue=alltrim(this.value)
if nKeyCode=13
with this.parent.parent
.validate(m.lcValue)
if .AllowAdd
.Container1.AddRemove1.cmdAdd.click()
.Container1.Command1.Refresh()
.Container1.List1.Refresh()
endif
endwith
nodefault
endif
And here is validate method in the form instance of this class:
lparameters tcValue
if len(m.tcValue) <> this.FieldLen
=messagebox('You should type '+alltrim(str(this.FieldLen))+' digits only!',48,'Warning...')
this.AllowAdd=.f.
return 0
else
return dodefault(m.tcValue)
endif
I'm also using InputMax property of the textbox...
If it's not broken, fix it until it is.
My Blog