
Signature
Regards
Jeff Boyce
<Office/Access MVP>
Thank you very much for information
Jesus Bless
Jemsson - 21 Dec 2005 07:39 GMT
Hello
Well, you don’t need to write above code I asked about that was after
IF........
because I wrote it and success, but now I found there is Detail High be
little when the text be more than 1 raw.
Do you know please how can I change “Derail.High” to be 2 cm ?
I mean by code in VB and not by properties setting.
Thank you
Hi again
This code you wrote it worked inside a field on form after I removing "IF
...".
But this question I need to use it on Report and this code will be on Detail
/Event / On print/Visual Basic
Do you have any ide how to write the code after THEN ..... ? Because all
code before IF I already have it, such as place on the page and font etc.
If Len([info]) > 18 then
print 18 of the [info] & But if the last word be more than 18 character then
back to last space “ “ And then make new raw & vbCr & and continue with
printing 18 character and if last word is more than 18 then back to last “ “
and make new raw so On
Wich mean it can be print in the raw 5 character, because it depent on last
word if it is long. But if it is shot then it can be printed 18 character.
Thanks
John Spencer - 21 Dec 2005 13:38 GMT
Here is a simple - not fully tested - function that should work in Access
2000 and later. Notice that this has no error-handling code built in.
Also, if a word exceeds the MaxLength then the entire word is returned as
one line. The assumption is that words are delimited by spaces.
For instance:
?SplitTolines("This is a test of my supercalifragilisticexpealidocious
simple code",18)
This is a test of
my
supercalifragilisticexpealidocious
simple code
'--------------------------------------------------------------------------
Public Function SplitToLines(StrIn, Optional MaxLength As Integer = 18)
'Takes a string and breaks it into 18 character lines
Dim vWords As Variant
Dim strOut As String
Dim iCount As Integer, iLength As Integer
If Len(StrIn & vbNullString) = 0 Then
SplitToLines = StrIn
Else
'Get all the words in the file
vWords = Split(StrIn, " ", -1, vbTextCompare)
For iCount = LBound(vWords) To UBound(vWords)
If iLength + Len(vWords(iCount) & "") < MaxLength Then
strOut = strOut & vWords(iCount) & " "
iLength = iLength + Len(vWords(iCount)) + 1
Else
strOut = strOut & vbCrLf & vWords(iCount) & " "
iLength = Len(vWords(iCount)) + 1
End If
Next iCount
SplitToLines = RTrim(strOut)
End If
End Function
> Hi again
>
[quoted text clipped - 22 lines]
>
> Thanks
John Spencer - 21 Dec 2005 13:46 GMT
I did a little more testing and came up with a modified version that has
error coding and strips off the final space on each line. Plus corrected an
error in the length calculation
Public Function SplitToLines(StrIn, Optional MaxLength As Integer = 20)
'Takes a string and breaks it into nn character length lines
'Works for Access 2000 and later
Dim vWords As Variant
Dim strOut As String
Dim iCount As Integer, iLength As Integer
On Error GoTo ERROR_SplitToLines
If Len(StrIn & vbNullString) = 0 Then
SplitToLines = StrIn
Else
'Get all the words in the file
vWords = Split(StrIn, " ", -1, vbTextCompare)
For iCount = LBound(vWords) To UBound(vWords)
If iLength + Len(vWords(iCount) & "") <= MaxLength Then
strOut = strOut & vWords(iCount) & " "
iLength = iLength + Len(vWords(iCount)) + 1
Else
strOut = RTrim(strOut) & vbCrLf & vWords(iCount) & " "
iLength = Len(vWords(iCount)) + 1
End If
Next iCount
SplitToLines = RTrim(strOut)
End If
EXIT_SplitToLines:
Exit Function
ERROR_SplitToLines:
SplitToLines = StrIn
'MsgBox "Error " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
" in procedure SplitToLines of Module Module1"
End Function
> Hi again
>
[quoted text clipped - 22 lines]
>
> Thanks
Jemsson - 21 Dec 2005 14:05 GMT
Hi John
Thank you very much
Jesus Bless you