• Text box won’t word wrap

    Author
    Topic
    #355648

    Using Access 2000 SR1. Any idea why a text box in a sub form won’t wrap text. It has vertical scroll bars, but won

    Viewing 0 reply threads
    Author
    Replies
    • #524947

      Does it have more than one line of text in the field? If not, there isn’t anyplace to scroll to. If you’re doing this for editing purposes, it might be better to use the double-click event of the textbox control to zoom the field instead. Then you wouldn’t need scroll bars and the user could see the entire contents of the field at once. Just stick [indent]


      RunCommand acCmdZoomBox


      [/indent] into the DoubleClick event procedure.

      • #524956

        Thanks. Yes I have used this elsewhere, but it still doesn’t get past the fact that the text box won’t scroll. The text box’s control source is a memo field. It can be 1 or 2 letters or a paragraph o several lines.

        • #525069

          have you tried setting the enter key behavior to new line in field instead of default
          HTH

          • #525082

            So simple! I’ve racked my brains for ages, and your solution enables scrolling like a charm.
            Thanks, you’re a genius.
            However, I still can’t get the text box to word wrap! Regards Peter

            • #655112

              You said the text box if being fed via a data set as a memo field. In the subform, check the data feeding the form to ensure you are getting all of the characters. If you are generating the dataset for the form through a query, the text box data is probably being cut to 255 characters. To get all of the characters, take the final query for the form and join to the table with the memo field. Then pass the memo field data from the table.

              HTH

      • #655063

        Charlotte,

        That would be the ONE!…thanks!

      • #655366

        Yes, many records have more than 1 line, and there is plenty of depth in the control to fit the text. As this was posted many months ago, I have since written code that wraps the text on the after update event. But I would sure like to know why it’s not wrapping of its own accord.
        .

        • #655374

          I have never seen this behavior in Access – most strange. If you zoom (Shift-F2) does the text wrap in the zoom box? Also have you tried having both vertical and horizontal scroll bars?

          • #655890

            I

            • #655894

              Do you actually see the vertical scrollbars? There’s a bug of sorts that doesn’t show scrollbars if you set the textbox margins to other than zero. Can you use the arrow keys to navigate to a second line even if the scrollbars don’t work, or is the rest of the value just not there?

            • #655924

              Yes, you can see the vertical scroll bars. Without my force warping code, the text just looks as if it extends beyond the edge of the text box, passing behind the scroll bars. The scroll bars just beep if you try to use them. Arrow keys do nothing. (because there is only 1 line?)
              With my forced wrapping, the text box scroll bars work just fine.

            • #655992

              Have you tried creating a new database and importing the objects from this one? That sounds like the form is corrupted because I can’t think of anything else that would make it behave this way. shrug

            • #656297

              Like you, I couldn

            • #656486

              Peter,

              With a little tweaking, you might be able to get the scroll bars to work.

              In the database I am using, the height of the textbox is set to 0.2. The textbox shows the scroll bars but they don’t work as they should.

              However, If I change the height to .2097, the scroll bars work properly. Even with the space limitations, perhaps a small increase in the height of the textbox will help.

              HTH

            • #656626

              Thanks Gary, I tried that, but no dice. However it

            • #656783

              Peter,

              Could you post your word wrap function.

              Thanks,

              Gary

            • #657068

              Call the function as:-
              NewNote = WrapText(Txt:=NewNote, MaxLgth:=45)

              Function WrapText(Txt As String, MaxLgth As Integer) As String
              ‘Called from
              ‘Forms_frmScratchNotes.Code Function EnterScratchNotes
              ‘Forms_frmTapesForPulling.Code Sub btnSendToExcel_Click
              ‘Txt As String, MaxLgth As Integer
              ‘Txt is passed string. MaxLgth is the maximum line lenght to be set.
              ‘Scratch Notes text box on main form show text if line is longer than is visible.
              ‘If scrolled, the next line is shown, not the text off the box on the previous line
              ‘format text to include Lf after Maxlgth chars
              Dim Cntr As Integer, X As Integer, Posn As Integer
              Dim L() As String, SpLine As String, ThisText As String, LastChar As String
              On Error GoTo Err_WrapText
              ReDim L(0 To 20)
              ‘Get rid of all Cr. (makes for easier parsing)
              Txt = Replace(Txt, vbCr, “”)
              ‘Get rid of any blank lines, ie, more than 1 vbLf in a row
              Posn = InStr(Txt, vbLf & vbLf)
              Do
              Txt = Replace(Txt, vbLf & vbLf, “”)
              Posn = InStr(Txt, vbLf & vbLf)
              Loop Until Posn = 0
              ‘Remove all the Lfs
              Txt = Replace(Txt, vbLf, ” “)
              Txt = Replace(Txt, ” “, ” “)
              L(0) = Txt
              ‘Now parse so that line length Becomes = MaxLgth Then
              SpLine = vbNullString
              Posn = InStrRev(L(Cntr), ” “, MaxLgth)
              If Posn = 0 Then ‘ie, no blanks. Split at MaxLgth
              SpLine = Left(L(Cntr), MaxLgth)
              L(Cntr) = Right(L(Cntr), Len(L(Cntr)) – MaxLgth)
              Else ‘ie, there is a blank
              SpLine = Left(L(Cntr), Posn)
              L(Cntr) = Right(L(Cntr), Len(L(Cntr)) – Posn)
              End If
              ‘Now move all rows down and make L(cntr)= SpLine
              If Len(SpLine) > 0 Then
              For X = 19 + 1 To Cntr + 1 Step -1
              If X > 0 Then
              If Len(L(X – 1)) > 0 Then
              L(X) = L(X – 1)
              End If
              End If
              Next X
              L(Cntr) = SpLine
              End If
              End If
              Next Cntr
              ReDim Preserve L(0 To Cntr)
              ThisText = Join(L(), vbCrLf)
              LastChar = Right(ThisText, 1) ‘Remove linefeed @ end, if it’s there.
              Do Until LastChar vbCrLf And LastChar vbCr And LastChar vbLf
              Select Case LastChar
              Case Is = vbCrLf, vbCr, vbLf
              ThisText = Left(ThisText, Len(ThisText) – 1)
              End Select
              LastChar = Right(ThisText, 1)
              Loop
              WrapText = ThisText
              Exit_WrapText:
              Exit Function

              Err_WrapText:
              gMsg = “We have an error in modMiscell” & vbCrLf & _
              “procedure WrapText()” & vbCrLf & _
              Err.Description & vbCrLf & _
              “Write down this error message and call Peter”
              MsgBox gMsg
              Resume Exit_WrapText
              Resume
              End Function

            • #656072

              Peter,

              Ineterestingly enough, I just encountered this same problem. I had to reduce the height of a textbox on a form due to space limitations so only one line is displayed. Prior to the reduction, the text wrapped as it should.

              However, if only one line is shown, the scroll up and down bars appear when the text exceeds the length of the textbox but you can only go to the end of the one line using the left right arrows or end button.

              I just tested the same box and increased its height and the scroll bars work as they should.

              I suppose that if only one line is being shown then there is nowhere to scroll down or up to.

            • #656314

              Thanks Gary, you

            • #656335

              It’s a pleasure, look at post 228243 grin

              Pat

            • #655895

              I have used text controls for memo fields and have never had any problems like that.
              This may sound a bit silly, but have you tried making the text box deeper (say 3 lines deep) and see if that solves the problem, I am guessing.
              Pat

            • #655925

              Thanks for the input Pat, but there is only room for 1

    Viewing 0 reply threads
    Reply To: Text box won’t word wrap

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: