web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Over come 80 character limit in calculated fields

(0) ShareShare
ReportReport
Posted on by 105

Please excuse me if this is simple question, I'm just starting with GP VBA.

I've got a report I'm trying to pull in some data in the form of a string, I can get the data I'm just having trouble displaying it using a calculated field as the max width is 80 characters (I'm very curious why there is any limit).

I've got the code below that works some times but is not stable. Does anyone know a better way to do this in VBA?

Thanks!

Note is the string I'm trying to break, String1-3 are eventually bound to the calculated fields

Private Sub SplitNote(Note As String, String1 As String, String2 As String, String3 As String)

    Dim Counter As Long
    
    Dim SplitLength As Integer
    Dim SplitStart As Long
    Dim SplitCount As Integer   ' Current split count
    SplitCount = 1
    SplitStart = 1
    
    Dim LastSpaceInstance As Long
    LastSpaceInstance = 1
    
       
    
    For Counter = 1 To Len(Note)
    
        ' if we are at a space and we've reached the string max
        ' go back to the previous space. Else, we will keep track
        ' of the last space instance
        If Mid(Note, Counter, 1) = " " And SplitLength >= 80 Then
        
            Select Case SplitCount
                Case 1
                    String1 = Mid(Note, SplitStart, LastSpaceInstance - SplitStart)
                Case 2
                    String2 = Mid(Note, SplitStart, LastSpaceInstance - SplitStart)
                Case 3
                    String3 = Mid(Note, SplitStart, LastSpaceInstance - SplitStart)
            End Select
            
            SplitStart = LastSpaceInstance + 1
            SplitCount = SplitCount + 1
            SplitLength = 0
            
    'Keeps track of the last space
        ElseIf (Mid(Note, Counter, 1) = " " And SplitLength < 80) Then
            
            LastSpaceInstance = Counter
    ' If there is an enter
        ElseIf (Mid(Note, Counter, 1) = Chr(13)) Then
            
            Select Case SplitCount
                Case 1
                    String1 = Mid(Note, SplitStart, Counter - SplitStart)
                Case 2
                    String2 = Mid(Note, SplitStart, Counter - SplitStart)
                Case 3
                    String3 = Mid(Note, SplitStart, Counter - SplitStart)
            End Select
            
            SplitStart = Counter + 1
            SplitCount = SplitCount + 1
            SplitLength = 0
        
        End If
    
        SplitLength = SplitLength + 1
    
    Next

    If (SplitLength <= 80) Then
    If Len(Note) > SplitStart Then
    SplitLength = Len(Note) - SplitStart
        Select Case SplitCount
            Case 1
                String1 = Mid(Note, SplitStart, SplitLength)
            Case 2
                String2 = Mid(Note, SplitStart, SplitLength)
            Case 3
                String3 = Mid(Note, SplitStart, SplitLength)
        End Select
    End If
    End If


*This post is locked for comments

I have the same question (0)
  • Almas Mahfooz Profile Picture
    11,009 User Group Leader on at

    If you are doing it in report then why not using RW functions to for calculated?

  • Kucster Profile Picture
    105 on at

    Thank you very much for your response. As I'm new to working with GP Reports, can you be more specific, I've found a great number of articles on RW but none specifically for my problem.

  • Suggested answer
    Justin Thorp Profile Picture
    2,265 on at

    You can download documentation regarding the RW functions here (Download the rw_func.zip):

    http://blogs.msdn.com/b/developingfordynamicsgp/archive/2008/09/01/using-the-built-in-report-writer-functions.aspx

    The specific one you are after is:

    RW_GetNoteText

    Module:                                   

    System Manager

     

    Series:

    System                                                                                                

     

    Script type:                             

    Global function                        

     

    Form (If a form global):           

     

     

    Category:                                

    Data Retrieval

     

    Description:                

    Returns Note Text field as strings of given length for the specified Note Index.

    Prerequisites:              

    none

     

    Parameters:                 

    in currency IN_NoteIndex.          { Note Index of Note }

    in integer IN_characters. { Number of Characters per Line }

    in integer IN_line.                       { Line Number to Return }

     

    Return Value:

    function returns string OUT_string.

    Thanks,
    Justin

  • Justin Thorp Profile Picture
    2,265 on at

    One point of clarification.  The above function helps with word wrapping, but the 80 character limit still applies.

  • Suggested answer
    L Vail Profile Picture
    65,271 on at

    Hi,

    You need to use the RW_ParseString function. Create a couple of calculated fields and use this function to split the string into a number of shorter strings.

    Kind regards,

    Leslie

  • Kucster Profile Picture
    105 on at

    Thank you very much for your responses and your help.

    I kind of understand the RW functions, the thing I'm missing is how to get the data from the VB Value to the calculated fields, no where does it day how to bound them.

    The goal of the program is to pull data from an unrelated table (Notes) and display it on the report. It would seem to me in order to use the RW functions the Table would have to be associated with the report

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

#1
mtabor Profile Picture

mtabor 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans