Control unbound field length

  • Thread starter Thread starter ricsantana
  • Start date Start date
R

ricsantana

Hello,


I have an unbound field in a Form. After updating, I am saving its
value in a table.

I need to control its length. It should not be possible for the user to
write more than the field size defined in the table.
How can I control the size of an unbound field size?

Tks in advance,
Ricardo.
(e-mail address removed)
 
Ricardo,

Would it serve your purpose to put code like this on the BeforeUpdate
event of the control in question?...
Private Sub YourTextbox_BeforeUpdate(Cancel As Integer)
If Len(Me.YourTextbox) > 99 Then
Cancel = True
MsgBox "eek!"
End If
End Sub
 
Hello,


I have an unbound field in a Form. After updating, I am saving its
value in a table.

I need to control its length. It should not be possible for the user to
write more than the field size defined in the table.
How can I control the size of an unbound field size?

Steve's suggestion will work, but won't give the user any feedback
until they leave the control. An alternative would be to use the
textbox's KeyDown event. Set the Form's KeyPreview property to True,
and put code like:

Private Sub txtX_KeyDown(KeyCode as Integer, Shift as Integer)
If Len(txtX.Text) > 100 Then
DoCmd.Beep
KeyCode = 0 ' cancel the keystroke
End If
End Sub
 
Back
Top