Link to home
Start Free TrialLog in
Avatar of mainrotor
mainrotor

asked on

I need help passing vbLF in a string to a textbox control in ACCESS 2010.

Hi Experts,
I have the following VBA code where I use vbLF in a string in my ACCESS application.  When I pass the string with the vbLF to my textbox control, the data is put in a single line.  There is no carriage return or line feed that occurs. How can I fix this?

See my code below
Private Sub viewEmail(strValues As String)
On Error GoTo ErrorHandler
         Dim rs2 As DAO.Recordset
         Dim db2 As Database
         Dim strSQL2 As String
         Dim strPassedValue As String
         Dim intJobId As Integer
         Dim strTech As String
         Dim varVals As Variant
         Dim strEmailMessage As String
         strPassedValue = strValues 'Me.OpenArgs
         
         varVals = Split(strPassedValue, "/")
         intJobId = CInt(Trim(varVals(0)))
         strTech = Trim(varVals(1))
         
         Set db2 = CurrentDb
         strSQL2 = "SELECT * FROM Schedule_Table WHERE JobID = " & intJobId & " AND Tech_Name = '" & strTech & "'"
         Set rs2 = db2.OpenRecordset(strSQL2)
          If rs2.RecordCount > 0 Then
            strEmailMessage = rs2![JobName] & vbLf
            strEmailMessage = strEmailMessage & rs2![VenueName] & vbLf
            strEmailMessage = strEmailMessage & rs2![AreaName] & vbLf
          Else
            MsgBox ("There was an issue generating the email text.")
          End If
        
        Me.txtEmailBody.Value = strEmailMessage

ExitSub:
'    Set rsScheduled = Nothing
    Exit Sub
ErrorHandler:
    MsgBox "Error No: " & Err.Number _
       & " in " & Me.ActiveControl.name & " procedure; " _
       & "Description: " & Err.Description
    
    Resume ExitSub
End Sub

Open in new window


thanks in advance,
mrotor
Avatar of ggzfab
ggzfab

A textbox won't allow CR's from the helpfile:
Up to 63,999 characters. (If the Memo field is manipulated through DAO and only text and numbers [not binary data] will be stored in it, then the size of the Memo field is limited by the size of the database.)
So to show this use a rich text control from the Active X controls.
SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial