cadalano
asked on
Access: Adding a new line to a text box via Control Source property?
In MS Access (version shouldn't matter), I have a Text Box control on a form w/ a recordset.
I have set the Control Source on the text box to =Replace([Field], ";", Chr(13))
[Field] is a colon-delimited string, and for each colon I want the string to line break in the text box.
However, Chr(13) is just showing up as a square box in the text field, instead of returning a new line. I know that I can probably get this done easily using VBA, but because the control is in the detail section of a contiguous form, it would be better for me to do it this way if possible. Am I missing something?
I have also tried the following, in place of Chr(13):
Chr(13) & Chr(15)
Chr(15)
"\r"
"\n"
"\r\n"
vbCrLf
vbNewLine
But none of them seem to work as a part of the Control Source property.
I have set the Control Source on the text box to =Replace([Field], ";", Chr(13))
[Field] is a colon-delimited string, and for each colon I want the string to line break in the text box.
However, Chr(13) is just showing up as a square box in the text field, instead of returning a new line. I know that I can probably get this done easily using VBA, but because the control is in the detail section of a contiguous form, it would be better for me to do it this way if possible. Am I missing something?
I have also tried the following, in place of Chr(13):
Chr(13) & Chr(15)
Chr(15)
"\r"
"\n"
"\r\n"
vbCrLf
vbNewLine
But none of them seem to work as a part of the Control Source property.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try:
=fnReplace([Field])
With a function call:
Function fnReplace(strField as string) As String
fnReplace = Replace([Field], ";", vbNewLine)
End Function
=fnReplace([Field])
With a function call:
Function fnReplace(strField as string) As String
fnReplace = Replace([Field], ";", vbNewLine)
End Function
Just in case you didn't have any ;
use:
Function fnReplace(strField as string) As String
If Instr(strField)>0 then
fnReplace = Replace([Field], ";", vbNewLine)
Else
fnReplace = strField
End If
End Function
Mike
use:
Function fnReplace(strField as string) As String
If Instr(strField)>0 then
fnReplace = Replace([Field], ";", vbNewLine)
Else
fnReplace = strField
End If
End Function
Mike
correction... replace [Field] with strField ... sorry
Function fnReplace(strField as string) As String
If Instr(strField)>0 then
fnReplace = Replace(strField, ";", vbNewLine)
Else
fnReplace = strField
End If
End Function
Function fnReplace(strField as string) As String
If Instr(strField)>0 then
fnReplace = Replace(strField, ";", vbNewLine)
Else
fnReplace = strField
End If
End Function
ASKER
the solution from DatabaseMX worked perfectly - I was just trying to use Chr(15) instead of Chr(10). Thanks for the help all!!
Thanks Mike ...
mx
mx
mx