dbTalk Databases Forums  

Limiting a Text Field's Input Size !

comp.databases.ms-access comp.databases.ms-access


Discuss Limiting a Text Field's Input Size ! in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Salad
 
Posts: n/a

Default Re: Limiting a Text Field's Input Size ! - 02-25-2008 , 05:27 PM






prakashwadhwani (AT) gmail (DOT) com wrote:
Quote:
On Feb 25, 10:42 pm, Salad <o... (AT) vinegar (DOT) com> wrote:

prakashwadhw... (AT) gmail (DOT) com 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 ...
Yes. I mentioned that it works when tabbing into a field. Albert gave
you a good workaround...click somewhere in the prior field and press
tab. As he noted, you are attempting to change the behavior of Windows.

Quote:
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 ?
Well, I suppose you could put it in the form's OnMouse events instead.
You might need to use the ActiveControl property.

Why doesn't
Quote:
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 ?

I entered in the OnEnter, OnGetFocus, and OnMouseDown a message box.
And this is the order it operates...so MouseDown is activated after
GetFocus.

Quote:
Any ideas or workarounds please ?

Use DOS.

Quote:
Best Rgds,
Prakash.

Reply With Quote
  #12  
Old   
Albert D. Kallal
 
Posts: n/a

Default Re: Limiting a Text Field's Input Size ! - 02-27-2008 , 04:43 PM






Arno, and Salad have posted some code.

just go:

If IsNull(Me.Text5) = True Then
Me.Text5.SelStart = 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
pleaseNOOSpamKallal (AT) msn (DOT) com



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.