Hello:
I have a continous form where I have a field called notes. It is text and I have a 255 chrc limit on it. I am limited to how wide this field can be. I do not want it to be a memo field but I would like to have my text box act and behave like one. That is that it will auto character turn the sentences and then a small scroll box would appear on the box for viewing purposes. Can that be done???
Thanks,
Keith.
7 2256
Hi Keith. If you resize the notes text box vertically to be two or three lines in length instead of the single line default you will find that text will wrap automatically. To have scroll bars shown for your users change the Scroll Bars property of the text box from None to Vertical.
-Stewart
Stewart:
Thanks for the reply. That did what I wanted it to do. I did have the settings as you suggested but found out that I need to have a minimum height on the text box to kick in the wrapping feature. In my case with Ariel 8 font the height had to be set to 0.24.
Since I set the character limitation to 255, is there a way to give the user a message box to tell them they have reached the limitation. Currently, Access just beeps.
Thanks,
Keith.
Stewart:
Thanks for the reply. That did what I wanted it to do. I did have the settings as you suggested but found out that I need to have a minimum height on the text box to kick in the wrapping feature. In my case with Ariel 8 font the height had to be set to 0.24.
Since I set the character limitation to 255, is there a way to give the user a message box to tell them they have reached the limitation. Currently, Access just beeps.
Thanks,
Keith.
- Let's assume your Text Box name is txtCharLength.
- Declare the following Constant in your Form's General declarations Section:
- Const MAXIMUM_NUM_OF_CHARACTERS As Integer = 255
- Copy and Paste the following code in the KeyPress() Event of txtCharLength:
- Private Sub txtCharLength_KeyPress(KeyAscii As Integer)
-
Dim txt As TextBox
-
Set txt = Me!txtCharLength
-
-
If Len(txt.Text) - txt.SelLength >= MAXIMUM_NUM_OF_CHARACTERS Then
-
'Let's allow the Backspace Key
-
If KeyAscii <> vbKeyBack Then
-
KeyAscii = 0 'Negate the Keystroke
-
MsgBox "You have reached the Maximum Number of Characters for this Text Box"
-
End If
-
End If
-
End Sub
- Copy and Paste the following code in the Change() Event of txtCharLength:
- Private Sub txtCharLength_Change()
-
Dim txt As TextBox
-
Dim Msg As String
-
-
'You must allow for the possibility that Text may be Copied and Pasted into
-
'this Text Box, ion which case the KeyPress() Event will never be fired
-
-
Msg = "You Text exceeds the Maximum Number of Characters allowed (255) for this " & _
-
"Text Box. The Text has been truncated to " & MAXIMUM_NUM_OF_CHARACTERS & _
-
" characters."
-
-
Set txt = Me!txtCharLength
-
-
If Len(txt.Text) > MAXIMUM_NUM_OF_CHARACTERS Then
-
MsgBox Msg
-
txt.Text = Left$(txt.Text, MAXIMUM_NUM_OF_CHARACTERS) 'truncate to Max
-
'Move the Cursor to the end of the Text Box
-
txt.SelStart = MAXIMUM_NUM_OF_CHARACTERS
-
End If
-
End Sub
- You should now be covered from every angle, any questions please feel free to ask.
This method gives the user a running count of how many characters they have left to type, then pops a warning box when they reach the limit.
Place a label above or next to the textbox.
Make the label's caption " 255 Characters Left"
Place this code behind the textbox: - Private Sub YourTextBox_Change()
-
CharacterCountLabel.Caption = 255 - Len(Me.YourTextBox.Text) & " Characters Left"
-
If Len(Me.YourTextBox.Text) = 255 Then
-
MsgBox "No more characters allowed!"
-
End If
-
End Sub
Linq ;0)>
[quote=ADezii][list=1][*] Let's assume your Text Box name is txtCharLength.[*] Declare the following Constant in your Form's General declarations Section: - Const MAXIMUM_NUM_OF_CHARACTERS As Integer = 255
[*] Copy and Paste .......................
ADezii:
I never needed to declare a constant in an object's general declarations section yet. How would I do that?
Thanks,
Keith.
ADezii:
I never needed to declare a constant in an object's general declarations section yet. How would I do that?
Thanks,
Keith.
I think I just found it in the VB window. I did the following: -
Option Compare Database
-
Const MAXIMUM_NUM_OF_CHARACTERS As Integer = 255
-
"Option Compare Database" was there as a default so I left it. Was that the correct way to input that?
Thanks for your help.
Keith.
Hello I just applyed the ideas and came up with this end result: -
Option Compare Database
-
Const MAXIMUM_NUM_OF_CHARACTERS As Integer = 255
-
-
Private Sub Comment_Change()
-
-
'Counts the amount of characters that remain to write in the comments text box
-
LblCharCount.Caption = 255 - Len(Me.Comment.Text) & " Characters Left"
-
If Len(Me.Comment.Text) = 255 Then
-
End If
-
End Sub
-
-
Private Sub Comment_KeyPress(KeyAscii As Integer)
-
-
'Will warn the user when they have reached the maximum character length
-
Dim txt As TextBox
-
Set txt = Me!Comment
-
-
If Len(txt.Text) - txt.SelLength >= MAXIMUM_NUM_OF_CHARACTERS Then
-
-
'Let's allow the Backspace Key
-
If KeyAscii <> vbKeyBack Then
-
KeyAscii = 0 'Negate the Keystroke
-
MsgBox "You have reached the Maximum Number of" & _
-
" Characters for the Comment section which is 255. Please refrase" & _
-
" your comments to shorten the length.", 64, "Max Characters Reached!"
-
-
'Move the Cursor to the end of the Text Box
-
txt.SelStart = MAXIMUM_NUM_OF_CHARACTERS
-
-
End If
-
End If
-
End Sub
-
I like the count down feature, cool stuff!
Thanks a lot to both of you!!
Keith :-)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ling Lee |
last post by:
Hi all.
I'm trying to write a program that:
1) Ask me what file I want to count number of lines in, and then counts the
lines and writes the answear out.
2) I made the first part like this:
...
|
by: ehm |
last post by:
I am working on creating an editable grid (for use in adding,
deleting, and editing rows back to an Oracle database). I have a JSP
that posts back to a servlet, which in turns posts to a WebLogic...
|
by: MLH |
last post by:
I have a 50-char job name field (text type) in an Access
table. The entries into this field will be unique. No two
records will house the same job name.
I would like an algorithm that would...
|
by: simonc |
last post by:
Help! I've created a text box which won't let me write in
it. It opens ready filled with text to the limit of the
number of characters which I've set (MaxLength=3200) and
this is in 40 lines of 80...
|
by: toby989 |
last post by:
Hi All
Sorry for reposting...the entries of the post from 11/23/2005 by Eric
Lindsay have been removed from the server already and I am seeing only
the header.
So, I have the problem of...
|
by: Bruce Lawson |
last post by:
Hi, I am confused about Microsofts description of this Transact SQL
reference; (Wildcard - Character(s) to Match. The description says
"Matches any single character within the specified range or...
|
by: FP |
last post by:
I have a javascript variable set to the contents of a database comments
field.
To set the js variable I used the PHP addslashes function which encodes
the apostrophe, double quotes and the...
|
by: Hallvard B Furuseth |
last post by:
Is the code below valid? Generally a value must be accessed
through the same type it was stored as, but there is an exception
for data stored through a character type. I'm not sure if that...
|
by: emojoy |
last post by:
So I have a project where there are 5 dynamic text fields, and I thought it would be quite simple. Create a dynamic text field, and then load in the .xml content, and I had it complete. However, it...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |