Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2005
    Posts
    79

    Unhappy Unanswered: Looping - Continuous Concatenating Not Working

    Hello, I am trying to add the previous value to the new value after the loop. However, it will only add (2) versious on the same record. When I loop through the first time, in the message box, I see everything that is needed, however, on subsequent loops, the message box displays the same information twice. Any help would be greatly appreciated. This seems really simple, however, I have tried numerous things with no luck. Thank you.

    Code:
    If .EOF And .BOF Then
            MsgBox "All is current at this time", vbOKOnly + vbInformation + vbDefaultButton2, "INFORMATION"
        Else
            .MoveFirst
                Do Until rs.EOF
                    strClass = rs![txtClass]
                    strCompleted = rs![dtofClass]
                    strFirstName = ![FirstName]
                    strLastName = rs![LastName]
                    strEmail = rs![Email] & ";"
                    strBody = strFirstName & " " & strLastName & vbTab & strClass & vbTab & "Due by: " & strCompleted & vbCrLf
                    'MsgBox strBody
                    Dim strTest As String
                    strTest = rs![FirstName] & " " & rs![LastName] & vbCrLf & rs![txtClass]
                    'MsgBox strBody & strTest
            .MoveNext
           'strBody = strFirstName & " " & strLastName & "     " & strClass + "     " & vbTab & "Due by:  " & strCompleted & vbCrLf & "          "
                Loop                
              End if

  2. #2
    Join Date
    Nov 2005
    Posts
    79

    Wink

    Quote Originally Posted by miracleblake View Post
    Hello, I am trying to add the previous value to the new value after the loop. However, it will only add (2) versious on the same record. When I loop through the first time, in the message box, I see everything that is needed, however, on subsequent loops, the message box displays the same information twice. Any help would be greatly appreciated. This seems really simple, however, I have tried numerous things with no luck. Thank you.

    Code:
    If .EOF And .BOF Then
            MsgBox "All is current at this time", vbOKOnly + vbInformation + vbDefaultButton2, "INFORMATION"
        Else
            .MoveFirst
                Do Until rs.EOF
                    strClass = rs![txtClass]
                    strCompleted = rs![dtofClass]
                    strFirstName = ![FirstName]
                    strLastName = rs![LastName]
                    strEmail = rs![Email] & ";"
                    strBody = strFirstName & " " & strLastName & vbTab & strClass & vbTab & "Due by: " & strCompleted & vbCrLf
                    'MsgBox strBody
                    Dim strTest As String
                    strTest = rs![FirstName] & " " & rs![LastName] & vbCrLf & rs![txtClass]
                    'MsgBox strBody & strTest
            .MoveNext
           'strBody = strFirstName & " " & strLastName & "     " & strClass + "     " & vbTab & "Due by:  " & strCompleted & vbCrLf & "          "
                Loop                
              End if
    I figured it out. I kept looking and looking and finally got it. I needed to initialize another variable. Before the loop utilized a strTest and set it to "", then added strTest = strTest & strBody.

  3. #3
    Join Date
    Jan 2012
    Posts
    23
    Code:
    MsgBox strBody & strTest
    Well your message box will always display same thing because you save recordset into variable and display both of them. Maybe you can give us more info...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •