Limiting a Text Field's Input Size !

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • prakashwadhwani@gmail.com

    #1

    Limiting a Text Field's Input Size !

    I've used Dbase/Clipper for years & Access for a little while now but
    Access doesn't seem to have any elegant solution to limiting the size
    of a text box ... i.e. the max number of characters that can be
    entered into a text box.

    In Dbase/Clipper eg. if memory serves me correctly, it's a 1-line
    elegant solution ..
    @ row, col get variable picture "@R50"

    or ... I could say var1=space(50)

    Now when I try to enter data into var1 it will allow a max of 50
    characters.

    Why don't the Access team make a small property specifying the max num
    of characters enterable ?

    I have seen Allen Browne's solution:
    How to limit the number of characters that can be typed into a text box in a Microsoft Access database, even where the box is not bound to a field that limits its length.


    I was just wondering if there's anything better.

    I tried using the format property with "C" repeated say 30 times ...
    but when entering data into the box I now see an underline/underscore
    over which I have to type ... looks ugly !

    Also ... when I click in the text box, the cursor goes somewhere in
    the middle of the text box & I have to press the home key to go to the
    beginning. Is there any workaround for this ?


    Thx & Best Rgds,
    Prakash.


  • Arno R

    #2
    Re: Limiting a Text Field's Input Size !


    <prakashwadhwan i@gmail.comschr eef in bericht news:313ef1df-5017-46d9-89d3-49476a07643a@e6 0g2000hsh.googl egroups.com...
    There are 3 UNBOUND textboxes on this form for which I'd like the foll
    behaviour:
    if the text box is empty, then whenever the text box gets focus, the
    cursor should go to the 1st character ... else it should follow the
    default behaviour.

    Would it be possible for either you or anyone else on this NG to
    please post some sample code which would permit me to do this ?

    Well I don't use inputmasks that much (I hate them), but sometimes when I need them I write simple code like:

    If IsNull(Me!Field WithInputMask) then
    Me!FieldWithInp utmask.SelStart =0
    Me!FieldWithInp utmask.SelLengt h=0
    End if

    btw: I am using the click event (user clicks with mouse)

    Arno R

    Comment

    • Albert D. Kallal

      #3
      Re: Limiting a Text Field's Input Size !

      Arno, and Salad have posted some code.

      just go:

      If IsNull(Me.Text5 ) = True Then
      Me.Text5.SelSta rt = 0
      End If

      If the field has somthing in it already...then it not null, and the above
      code will not run, and you get default behavour...


      --
      Albert D. Kallal (Access MVP)
      Edmonton, Alberta Canada
      pleaseNOOSpamKa llal@msn.com


      Comment

      Working...