Re: Limiting a Text Field's Input Size !
- From: prakashwadhwani@xxxxxxxxx
- Date: Mon, 25 Feb 2008 12:57:14 -0800 (PST)
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.
.
- References:
- Limiting a Text Field's Input Size !
- From: prakashwadhwani
- Re: Limiting a Text Field's Input Size !
- From: Salad
- Re: Limiting a Text Field's Input Size !
- From: prakashwadhwani
- Limiting a Text Field's Input Size !
- Prev by Date: Re: Access 2007
- Next by Date: Re: Access 2007
- Previous by thread: Re: Limiting a Text Field's Input Size !
- Next by thread: Re: Limiting a Text Field's Input Size !
- Index(es):
Relevant Pages
|