Line/Carriage Return in MS Access Text Box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dee Brooks
    New Member
    • May 2007
    • 4

    Line/Carriage Return in MS Access Text Box

    Hello,

    I'm using Access 2002 to create a text box that will contain the following information in this format:

    Name
    Title
    Company
    City, State
    email

    I entered the following expression in a text box:

    =[FULL_NAME] & Chr(10) & Chr(13) & [TITLE] & Chr(10) & Chr(13) & [COMPANY] & Chr(10) & Chr(13) & [CITY_STATE] & Chr(10) & Chr(13) & [EMAIL]

    This is the result of the expression:

    Name   Title   Company   City, State   email

    I've tried using Chr(10) only and Chr(13) only, but I still cannot get each field to appear on a separate line. Does anyone have any suggestions.

    Thanks!
  • pyropowers
    New Member
    • May 2007
    • 3

    #2
    If you going to be looking through records and want this to show up, you could create an event on Current. You would also have to have the fields actually in the form, but make them not visible.

    Private Sub Form_Current()
    Form_Form1.Text 0.SetFocus
    Form_Form1.Text 0.Text = ""
    If IsNull(Form_For m1.Full_Name) = False Then
    Form_Form1.Text 0.Text = Form_Form1.Full _Name
    End If
    If IsNull(Form_For m1.Title) = False Then
    Form_Form1.Text 0.Text = Form_Form1.Text 0.Text & vbNewLine & Form_Form1.Titl e
    End If
    If IsNull(Form_For m1.Company) = False Then
    Form_Form1.Text 0.Text = Form_Form1.Text 0.Text & vbNewLine & Form_Form1.Comp any
    End If
    If IsNull(Form_For m1.City_State) = False Then
    Form_Form1.Text 0.Text = Form_Form1.Text 0.Text & vbNewLine & Form_Form1.City _State
    End If
    If IsNull(Form_For m1.Email) = False Then
    Form_Form1.Text 0.Text = Form_Form1.Text 0.Text & vbNewLine & Form_Form1.Emai l
    End If
    End Sub

    Comment

    • Dee Brooks
      New Member
      • May 2007
      • 4

      #3
      The text box I'm setting up is for an Access report, not in a form. Will the formula below work?




      Originally posted by pyropowers
      If you going to be looking through records and want this to show up, you could create an event on Current. You would also have to have the fields actually in the form, but make them not visible.

      Private Sub Form_Current()
      Form_Form1.Text 0.SetFocus
      Form_Form1.Text 0.Text = ""
      If IsNull(Form_For m1.Full_Name) = False Then
      Form_Form1.Text 0.Text = Form_Form1.Full _Name
      End If
      If IsNull(Form_For m1.Title) = False Then
      Form_Form1.Text 0.Text = Form_Form1.Text 0.Text & vbNewLine & Form_Form1.Titl e
      End If
      If IsNull(Form_For m1.Company) = False Then
      Form_Form1.Text 0.Text = Form_Form1.Text 0.Text & vbNewLine & Form_Form1.Comp any
      End If
      If IsNull(Form_For m1.City_State) = False Then
      Form_Form1.Text 0.Text = Form_Form1.Text 0.Text & vbNewLine & Form_Form1.City _State
      End If
      If IsNull(Form_For m1.Email) = False Then
      Form_Form1.Text 0.Text = Form_Form1.Text 0.Text & vbNewLine & Form_Form1.Emai l
      End If
      End Sub

      Comment

      • puppydogbuddy
        Recognized Expert Top Contributor
        • May 2007
        • 1923

        #4
        I think all you have to do is highlight the textbox control, invoke the property sheet and set the following two properties as shown. It may or may not require a rich text box in order to work:

        Enter Key Behavior = New Line in Field
        Can Grow = Yes or No (Your choice for the textbox itself)

        Comment

        • compaqdrew
          New Member
          • Jun 2007
          • 1

          #5
          I just found this, and the code monkeys and I laughed for about ten minutes.

          =[Field_1]+ "
          " + [Field_2]

          Try it. Seriously.

          [Ctrl+Enter lets you insert that line break in the code in design view]

          Comment

          Working...