Help needed

Tark221

Registered User.
Local time
Today, 23:12
Joined
Oct 12, 2012
Messages
74
I'm struggling to find a solution to my problem. I have a box with a long note in, I want to click a button and transfer it to another box but in the second box I need each line to be 75 characters only.

So every 75 characters there needs to be a new line.

Any help is much appreciated

Thanks
 
There my be more elegant and/or more efficient code, but this seems to work:
Code:
  Dim str As String
  Dim str2 As String
  str = Me.Text1
  Do Until Len(str) = 0
    str2 = Left(str, 75)
    Me.Text2 = Me.Text2 & str2 & vbNewLine
    If Len(str) > 74 Then
      str = Right(str, Len(str) - 75)
    Else
      Exit Do
    End If
      
  Loop
Text1 is the name of the control showing the long string of text and Text2 is the name of the control showing the amended text.
 
Ah I just tried that with a test form and works perfectly thank you, one more thing. The code I current use is
Dim intCount As Integer
Dim iBox As Integer

'COUNT TOTAL CHARACTERS IN NOTE

intCount = Len([Forms]![LoggingForm].[tbNote])

'DIVIDE THE TOTAL BY THE PAGE LIMIT 208 TO WORK OUT HOW MANY BOXES ARE NEEDED

endCount = [Forms]![LoggingForm]![NoteMarker].Caption
txtboxcnt = 208

iBox = 1
For iBox = 1 To endCount
Me.Controls("TextBox" & iBox) = Left([Forms]![LoggingForm].[tbNote], 208)
[Forms]![LoggingForm].[tbNote] = Mid([Forms]![LoggingForm].[tbNote], 209)

intCount = intCount - 208
Next iBox

This takes the box with the large note in and transfers it to dynamically made textboxes 208 characters at a time as this is the maximum limit per textbox for my requirements. How would I in corperate it with your code so it has 75 characters a line but still 208 characters a textbox.

Any help would be appreciated

thanks
 
...How would I in corperate it with your code so it has 75 characters a line but still 208 characters a textbox.
Sorry, I don't understand the requirement. What will the other 133 characters be.
 
Sorry for not being very clear.

So I have a text box with a large note in. Lets say the note is 850 characters, I want to transfer that into multiple text box's. The requirements are, each box can only hold 208 characters and each line in a box can only be 75 characters a line before it starts a new line.

When I click the button it takes the amount of characters in the note box which from the example above is 850, divides it by 208 and this gives me how many text box the code needs to create. I then need to fill those text boxes with the requirements above.

I already have a function which creates the text boxes and fills them 208 characters a box. It's the 75 characters a line bit I'm struggling with.

It's a bit of a puzzle to explain lol.

I hope this is a clearer explanation.

Thanks
 
Is this readable text that is supposed to make sense? Perhaps you can't break the string into 75 char lines if you break in mid word. Perhaps it's the first space that's immediately before character in position 75.
If position 75 is not space then what position closest to 75 has a space.
Just a thought for consideration. In fact, a readable line could terminate with a comma, a space, a period, a question mark or an exclamation. So you may have to check for each of these at position 75, or the one closest, yet lower, than 75.
 
Last edited:
for the purpose of what is needed it doesnt have to be clear and readable, it's just pasted into a program which store's it.
 
So, if you can have
I already have a function which creates the text boxes and fills them 208 characters a box.
and all you're doing is storing it, why do you have to deal with lines?
Are you having issues with Bob's code from post #2?
What exactli is the problem at the moment?
 
for the purpose of what is needed it doesnt have to be clear and readable, it's just pasted into a program which store's it.
If Access is to be the program that stores it, perhaps you should be looking at how to to save each line of text in a field of a table. This table could represent the many side of a one to many relationship, where the whole text string would be the one side.
 
Agree Bob. Perhaps the original poster can tell us again in plain English about the requirement. Seems we're all jumping at a few symptoms with guesses. I think we need to here about the source, the issue, the eventual storage location and how familiar he/she is with vba.
 

Users who are viewing this thread

Back
Top Bottom