A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

maximum number of characters



 
 
Thread Tools Display Modes
  #1  
Old February 25th, 2008, 02:46 AM posted to microsoft.public.access,microsoft.public.access.forms
-Obama
external usenet poster
 
Posts: 15
Default maximum number of characters

I am using access 97. How do I limit the number of character of a control in
a form at form level? Thanks.


  #2  
Old February 25th, 2008, 05:45 AM posted to microsoft.public.access,microsoft.public.access.forms
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default maximum number of characters

-Obama,
you could do this in the table by adjusting the Field Size property for
that
field if it is a text field.

For a number field you could write a validation rule for the table like
this:
For a field called MyNbrTest
Validation rule: Len([MyNbrTest])7
Validation text: No more than 6 digits allowed

Jeanette Cunningham

" -Obama" wrote in message
...
I am using access 97. How do I limit the number of character of a control
in a form at form level? Thanks.




  #3  
Old February 25th, 2008, 05:48 AM posted to microsoft.public.access,microsoft.public.access.forms
-Obama
external usenet poster
 
Posts: 15
Default maximum number of characters

Thanks, Can I do it in a form level?


"Jeanette Cunningham" wrote in message
...
-Obama,
you could do this in the table by adjusting the Field Size property for
that
field if it is a text field.

For a number field you could write a validation rule for the table like
this:
For a field called MyNbrTest
Validation rule: Len([MyNbrTest])7
Validation text: No more than 6 digits allowed

Jeanette Cunningham

" -Obama" wrote in message
...
I am using access 97. How do I limit the number of character of a control
in a form at form level? Thanks.






  #4  
Old February 25th, 2008, 05:52 AM posted to microsoft.public.access,microsoft.public.access.forms
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default maximum number of characters

In the before update event for the control

If Len(Me.ControlName.Text) 6 Then
Msgbox "No more than 6 characters allowed"
Cancel = True
End If

Jeanette Cunningham

" -Obama" wrote in message
...
Thanks, Can I do it in a form level?


"Jeanette Cunningham" wrote in message
...
-Obama,
you could do this in the table by adjusting the Field Size property for
that
field if it is a text field.

For a number field you could write a validation rule for the table like
this:
For a field called MyNbrTest
Validation rule: Len([MyNbrTest])7
Validation text: No more than 6 digits allowed

Jeanette Cunningham

" -Obama" wrote in message
...
I am using access 97. How do I limit the number of character of a control
in a form at form level? Thanks.








  #5  
Old February 25th, 2008, 07:55 AM posted to microsoft.public.access.forms,microsoft.public.access
boblarson
external usenet poster
 
Posts: 886
Default maximum number of characters

Or you can use the KeyDown event to capture the keystrokes and, by using the
Len() function you can test for the length and then cancel any other
keystrokes if the length has been reached.

For example:

Private Sub MyTextBoxName_KeyDown(KeyCode As Integer, Shift As Integer)
If Len(Me.MyTextBoxName.Text) = 6 Then
KeyCode = 0
Msgbox "Only 6 characters allowed!", vbExclamation,"Max Length
Reached"
End If
End Sub

--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
If my post was helpful to you, please rate the post.
__________________________________


"-Obama" wrote:

Thanks, Can I do it in a form level?


"Jeanette Cunningham" wrote in message
...
-Obama,
you could do this in the table by adjusting the Field Size property for
that
field if it is a text field.

For a number field you could write a validation rule for the table like
this:
For a field called MyNbrTest
Validation rule: Len([MyNbrTest])7
Validation text: No more than 6 digits allowed

Jeanette Cunningham

" -Obama" wrote in message
...
I am using access 97. How do I limit the number of character of a control
in a form at form level? Thanks.







 




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 Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:17 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.