Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Reports / Printing / December 2005

Tip: Looking for answers? Try searching our database.

18 chracter

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jemsson - 20 Dec 2005 09:38 GMT
Hello

I need code that can make calculate field [info] and then will do as this
explained:

If  [info] > 18 chracter then
print 18 of the [info] & But if the last word be more than 18 character then
back to last space “ “ And them 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.

Thank you for your help
Jeff Boyce - 20 Dec 2005 13:25 GMT
Jemsson

If [info] > 18 character

probably won't do what you expect, and probably won't work at all.

I suspect you want to know if the "length" of what's stored in [info] is
greater than 18 characters.  If so, try:

   If len([info]) > 18 then
       ...

Signature

Regards

Jeff Boyce
<Office/Access MVP>

> Hello
>
[quoted text clipped - 11 lines]
>
> Thank you for your help
Jemsson - 20 Dec 2005 22:08 GMT
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
Jemsson - 20 Dec 2005 22:32 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.