Solved Line break in text box of form (1 Viewer)

AnilBagga

Member
Local time
Today, 20:30
Joined
Apr 9, 2020
Messages
223
I need to add a line break in an expression of a text box. The internet search yielded an expression &VbCrLf& for a line break. This does not help

The expression used was

="A="&" "&DLookUp("packingtext","tblpacking","Abbreviationpacking='A'") & vbCrLf & "B="&" "&DLookUp("packingtext","tblpacking","Abbreviationpacking='B'")

The result needed is as below. What is the correct replacement of & vbCrLf &

A= Expression 1
B= Expression 2 etc
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:00
Joined
May 7, 2009
Messages
19,230
is this in query?
use Chr(10) & Chr(13), in place of vbCrLf.
 

AnilBagga

Member
Local time
Today, 20:30
Joined
Apr 9, 2020
Messages
223
is this in query?
use Chr(10) & Chr(13), in place of vbCrLf.
I still get the output as per screen shot below. The expression is

="A="&" "&DLookUp("packingtext","tblpacking","Abbreviationpacking='A'") & Chr(10) & Chr(13) & "B="&" "&DLookUp("packingtext","tblpacking","Abbreviationpacking='B'")

1630922102592.png
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:00
Joined
May 7, 2009
Messages
19,230
can you use an Event to set the value instead of an Expression, example:

private sub form_current()
me.textbox = "A="&" "&DLookUp("packingtext","tblpacking","Abbreviationpacking='A'") & vbcrlf & "B="&" "&DLookUp("packingtext","tblpacking","Abbreviationpacking='B'")
end sub
 

AnilBagga

Member
Local time
Today, 20:30
Joined
Apr 9, 2020
Messages
223
can you use an Event to set the value instead of an Expression, example:

private sub form_current()
me.textbox = "A="&" "&DLookUp("packingtext","tblpacking","Abbreviationpacking='A'") & vbcrlf & "B="&" "&DLookUp("packingtext","tblpacking","Abbreviationpacking='B'")
end sub
Works perfectly. Thanks Arnel
 

AnilBagga

Member
Local time
Today, 20:30
Joined
Apr 9, 2020
Messages
223
can you use an Event to set the value instead of an Expression, example:

private sub form_current()
me.textbox = "A="&" "&DLookUp("packingtext","tblpacking","Abbreviationpacking='A'") & vbcrlf & "B="&" "&DLookUp("packingtext","tblpacking","Abbreviationpacking='B'")
end sub
Arnel,

1. This text box is in the footer of a report. Sorry for the error. It works perfectly though when I create the report, using Report view.

2. Sometime back you had helped me provide the module as below to export files in pdf with a file name.

3. IHowever when I use this module below, the text box is empty. Frankly the code below is much beyond my capacity to understand to be able to edit it for populating the text box

Will appreciate help!

Code:
Option Compare Database

Public Function fncSerialFile(ByVal strFilePath As String) As String
'
' arnelgp
'
' strFilePath is the "path" + "filename.ext"
' example:
'
' "d:\ContainersTransit.xlsx" or
' "d:\ContainersTransit.pdf"
'
'
' returns:
'
' "d:\ContainersTransit-DDMMYYYY-X.xlsx"
' "d:\ContainersTransit-DDMMYYYY-X.pdf"
'
    Dim strNewFile As String
    Dim strPath As String
    Dim strFile As String
    Dim strExt As String
    Dim intX As Integer
    strPath = fncFilePath(strFilePath)
    strExt = fncFileExtension(strFilePath)
    strFile = Replace(strFilePath, strPath, vbNullString)
    strFile = Replace(strFile, strExt, vbNullString)
    strNewFile = strPath & strFile & "-" & Format(Date, "DDMMYYYY") & "-" & intX & strExt
    Do Until Len(Dir(strNewFile)) = 0
        intX = intX + 1
        strNewFile = strPath & strFile & "-" & Format(Date, "DDMMYYYY") & "-" & intX & strExt
    Loop
    fncSerialFile = strNewFile
End Function

Public Function fncFilePath(ByVal strFile As String) As String
    ' return path with backslash
    Dim intX As Integer
    intX = InStrRev(strFile, "\")
    If intX > 0 Then
        fncFilePath = Left$(strFile, intX)
    End If
End Function

Public Function fncFileExtension(ByVal strFile As String)
    Dim intX As Integer
    intX = InStrRev(strFile, ".")
    If intX > 0 Then
        fncFileExtension = Mid(strFile, intX)
    End If
End Function
 

bastanu

AWF VIP
Local time
Today, 08:00
Joined
Apr 13, 2010
Messages
1,402
Hi Anil,
You might want to move Arnel's code to the Format (or Print) event of the footer section of the report containing the text box.
Cheers,
 

AronGuru

New member
Local time
Today, 11:00
Joined
Jul 4, 2023
Messages
1
is this in query?
use Chr(10) & Chr(13), in place of vbCrLf.
This should be the other way around. Chr(13) & Chr(10). First the 13 then the 10. (13 = CR and 10 = LF)
Now it works perfectly.
 

Users who are viewing this thread

Top Bottom