Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2010
    Posts
    21

    Managing Text Output Format in Notepad

    Hi

    I am making an Access app for use at work. Part of the function is to output the invoice words to Notepad for transfer to the accounting software easily.

    I want to produce a notepad text with format like:

    1234 Went to site and did something $120.00
    2345 Whilst on site we noticed a screw
    was missing in the widget so we
    put a plug in $180.00


    1334 Job is complete $120.00

    I can make the format fit 1234 and 1334 simply enough using space minus length. My issue is how to format 2345 to truncate the lines of text if over a specific length. I cant even see how to start to do this.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I am guessing would have to use string manipulation functions (Left, Mid, InStr, Len) in looping structure to progressively write substrings of the lengthy text.

    What is 'space'? How many characters should be allowed on each line? You don't want words split? Consider (I picked 50 as the line length):
    Code:
    Function testNotepad(strIn)
    Dim strA As String, intP As Integer
    While Len(strIn) > 0
        If Len(strIn) > 50 Then
            intP = InStrRev(Left(strIn, 50), " ") - 1
            strA = Left(strIn, intP)
            strIn = Mid(strIn, intP + 2)
        Else
            strA = strIn
            strIn = ""
        End If
        Debug.Print strA
    Wend
    End Function
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 15
    Last Post: 07-10-2013, 01:27 PM
  2. Replies: 1
    Last Post: 02-12-2013, 09:12 AM
  3. Replies: 7
    Last Post: 08-13-2012, 06:59 AM
  4. Querry IIf Output Format (Access 2003)
    By Bruce in forum Access
    Replies: 2
    Last Post: 12-03-2009, 06:52 PM
  5. Output Query to Text
    By denileigh in forum Queries
    Replies: 1
    Last Post: 05-27-2006, 12:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums