• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 738
  • Last Modified:

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
0
mainrotor
Asked:
mainrotor
2 Solutions
 
ggzfabCommented:
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.
0
 
Gustav BrockCIOCommented:
You have to use vbCrLf or vbNewLine, not vbLf.

/gustav
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Or you can use:
strEmailMessage = rs2![JobName] & Chr(13) & Chr(10)

"A textbox won't allow CR's from the helpfile:"
Sorry, but that's not true.  You can most definitely enter a LFCR in a Text Box.
And on the Property Sheet of a Text Box, you can set Enter Key Behavior to "New Line in Field"

mx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now