Re: Limiting a Text Field's Input Size !



On Feb 26, 12:31 am, prakashwadhw...@xxxxxxxxx wrote:
On Feb 25, 10:42 pm, Salad <o...@xxxxxxxxxxx> wrote:







prakashwadhw...@xxxxxxxxx wrote:
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:
http://allenbrowne.com/ser-34.html

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 !

Not sure why you are using Format. If you click under the data tab you
can use an InputMask. Here's an example of limiting to 5 characters
with no guide.
CCCCC;;" "

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 ?

I'm not aware of a solution. That doesn't mean there isn't one. If I
entered in the GotFocus events
If len(Me.TextFieldName) > 5 then
Me.TextFieldName.SelStart = 5
Me.TextFieldName.SelLength = 2
Endif
and I tabbed to the field then the insertion point would be at the fifth
character and the 5th/6th chars would be selected.

ICGirlshttp://www.youtube.com/watch?v=HJ0pABDh_gw

Thx & Best Rgds,
Prakash.

I tried this, but the insertion point goes to the 1st character only
if I tab into the textbox ... not if i click in the textbox. Here's my
code ...

Private Sub txt_RcdFm_PdTo_GotFocus()
If Nz(Len(Me.txt_RcdFm_PdTo)) = 0 Then
MsgBox "Setting Cursor to 1st char"
Me.txt_RcdFm_PdTo.SelStart = 0
End If
End Sub

Will i have to put this same code in another event too ? Why doesn't
it work here ? The gotfocus event seems the most logical compared to
a MouseClick or MouseDown event, because in any case I'd have to even
check to see if the user has tabbed into the field. That means
checking in 2 events ?

Any ideas or workarounds please ?

Best Rgds,
Prakash.



Ok ... I've got it to work by using the foll code:

Private Sub txt_RcdFm_PdTo_GotFocus()
If Nz(Len(Me.txt_RcdFm_PdTo)) = 0 Then 'if the textbox is
EMPTY
Me.txt_RcdFm_PdTo.SelStart = 0 'Position Cursor at
1st char
SendKeys "{HOME}"
Else 'if the textbox has
some data
Me.txt_RcdFm_PdTo.SelLength = 0
Me.txt_RcdFm_PdTo.SelStart = Len(Me.txt_RcdFm_PdTo)
'Position Cursor after LAST char
End If
End Sub

My problem is that if I tab into the textbox & it has data the cursor
is positioned correctly, but if I CLICK into the textbox having data,
the cursor flashes at the clicked position.

Is there another workaround like I've used Sendkeys above ? Sendkeys
seems to work perfectly for both - if I tab into & if i click into the
textbox.

Rgds,
Prakash.
.



Relevant Pages

  • Re: [opensuse] AWK -- Strange chars used as separators in a CSV like file
    ... I have a CSV like file that uses the octal single byte char 024 (or ... cntrl-T) as a comma and 0376 as ... In vi move to the column in the line where you need to delete and type 999 then x and it will remove 999 characters from the cursor going to the right. ...
    (SuSE)
  • Re: enter or tab exit textbox
    ... >that only enter or tab to exit the cursor from textbox and not able by ... characters. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Can isspace() ever be true?
    ... I hope no such locale actually exists. ... base, and a final string of one or more unrecognized characters, ... unsigned long int ustrtoul(const char *nptr, char **endptr, ... equivalently declaring cursor as a const unsigned char*.) ...
    (comp.lang.c)
  • Re: Textboxes and their influence on the behaviour of ranges
    ... The test inside the Textbox is held as a TextRange within a TextFrame within the Textbox Shape. ... It is also part of the document's TextFrame Story (which is actually a series of stories, one per Textbox or, strictly, one per chain of textboxes - if you have linked ones). ... You can process the Characters in this Range in the same way you processed those in the main document. ... ....and my cursor is in the text box. ...
    (microsoft.public.word.vba.general)
  • Event cancel
    ... I would you like to capture a keyPress or KeyDown event and checking wich ... characters was pressed and if the char is not allowed I want to Cancel the ... In a textBox I want to allow insert of only number or character that I ... select and if sameone press another char I simply want to do nothing. ...
    (microsoft.public.dotnet.languages.csharp)