473,396 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Text box with character turns....

kcdoell
230 100+
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.
Mar 28 '08 #1
7 2256
Stewart Ross
2,545 Expert Mod 2GB
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
Mar 28 '08 #2
kcdoell
230 100+
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.
Apr 1 '08 #3
ADezii
8,834 Expert 8TB
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.
  1. Let's assume your Text Box name is txtCharLength.
  2. Declare the following Constant in your Form's General declarations Section:
    Expand|Select|Wrap|Line Numbers
    1. Const MAXIMUM_NUM_OF_CHARACTERS As Integer = 255
  3. Copy and Paste the following code in the KeyPress() Event of txtCharLength:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub txtCharLength_KeyPress(KeyAscii As Integer)
    2. Dim txt As TextBox
    3. Set txt = Me!txtCharLength
    4.  
    5. If Len(txt.Text) - txt.SelLength >= MAXIMUM_NUM_OF_CHARACTERS Then
    6.   'Let's allow the Backspace Key
    7.   If KeyAscii <> vbKeyBack Then
    8.     KeyAscii = 0        'Negate the Keystroke
    9.       MsgBox "You have reached the Maximum Number of Characters for this Text Box"
    10.   End If
    11. End If
    12. End Sub
  4. Copy and Paste the following code in the Change() Event of txtCharLength:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub txtCharLength_Change()
    2. Dim txt As TextBox
    3. Dim Msg As String
    4.  
    5. 'You must allow for the possibility that Text may be Copied and Pasted into
    6. 'this Text Box, ion which case the KeyPress() Event will never be fired
    7.  
    8. Msg = "You Text exceeds the Maximum Number of Characters allowed (255) for this " & _
    9.       "Text Box. The Text has been truncated to " & MAXIMUM_NUM_OF_CHARACTERS & _
    10.       " characters."
    11.  
    12. Set txt = Me!txtCharLength
    13.  
    14. If Len(txt.Text) > MAXIMUM_NUM_OF_CHARACTERS Then
    15.   MsgBox Msg
    16.   txt.Text = Left$(txt.Text, MAXIMUM_NUM_OF_CHARACTERS)       'truncate to Max
    17.   'Move the Cursor to the end of the Text Box
    18.   txt.SelStart = MAXIMUM_NUM_OF_CHARACTERS
    19. End If
    20. End Sub
  5. You should now be covered from every angle, any questions please feel free to ask.
Apr 2 '08 #4
missinglinq
3,532 Expert 2GB
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:

Expand|Select|Wrap|Line Numbers
  1. Private Sub YourTextBox_Change()
  2.   CharacterCountLabel.Caption = 255 - Len(Me.YourTextBox.Text) & " Characters Left"
  3.   If Len(Me.YourTextBox.Text) = 255 Then
  4.     MsgBox "No more characters allowed!"
  5.   End If
  6. End Sub
Linq ;0)>
Apr 2 '08 #5
kcdoell
230 100+
[quote=ADezii][list=1][*] Let's assume your Text Box name is txtCharLength.[*] Declare the following Constant in your Form's General declarations Section:
Expand|Select|Wrap|Line Numbers
  1. 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.
Apr 2 '08 #6
kcdoell
230 100+

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:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Const MAXIMUM_NUM_OF_CHARACTERS As Integer = 255
  3.  
"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.
Apr 2 '08 #7
kcdoell
230 100+
Hello I just applyed the ideas and came up with this end result:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Const MAXIMUM_NUM_OF_CHARACTERS As Integer = 255
  3.  
  4. Private Sub Comment_Change()
  5.  
  6. 'Counts the amount of characters that remain to write in the comments text box
  7.     LblCharCount.Caption = 255 - Len(Me.Comment.Text) & " Characters Left"
  8.         If Len(Me.Comment.Text) = 255 Then
  9.             End If
  10. End Sub
  11.  
  12. Private Sub Comment_KeyPress(KeyAscii As Integer)
  13.  
  14. 'Will warn the user when they have reached the maximum character length
  15. Dim txt As TextBox
  16. Set txt = Me!Comment
  17.  
  18. If Len(txt.Text) - txt.SelLength >= MAXIMUM_NUM_OF_CHARACTERS Then
  19.  
  20. 'Let's allow the Backspace Key
  21.   If KeyAscii <> vbKeyBack Then
  22.     KeyAscii = 0        'Negate the Keystroke
  23.          MsgBox "You have reached the Maximum Number of" & _
  24.     " Characters for the Comment section which is 255. Please refrase" & _
  25.     " your comments to shorten the length.", 64, "Max Characters Reached!"
  26.  
  27. 'Move the Cursor to the end of the Text Box
  28.   txt.SelStart = MAXIMUM_NUM_OF_CHARACTERS
  29.  
  30.   End If
  31. End If
  32. End Sub
  33.  
I like the count down feature, cool stuff!

Thanks a lot to both of you!!

Keith :-)
Apr 2 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

22
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: ...
2
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...
3
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...
4
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...
7
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...
1
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...
2
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...
21
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...
0
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...
0
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
1
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...
0
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.