We help IT Professionals succeed at work.
Get Started

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

902 Views
Last Modified: 2016-02-10
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
Comment
Watch Question
Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007
Commented:
This problem has been solved!
Unlock 2 Answers and 3 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE