Concatenate records of same field (1 Viewer)

georg0307

Registered User.
Local time
Today, 07:53
Joined
Sep 11, 2014
Messages
91
Dear all,
I have a table with filed "Shipments", with i.e. the following records:

1234567
5432188
2345678
5555555

in need in a textbox in the report that shows the data concatenated: 1234567_5432188_2345678_5555555

And in second moment name a PDF output with this text:

1234567_5432188_2345678_5555555.pdf

Could you please help?

Thanks in advance,

Georg
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:53
Joined
May 7, 2009
Messages
19,247
you can open a recordset from your table and loop through it:

Code:
public function concatField(byval tableName as string, byval fldName as string, optional byval criteria as string="(1=1)") as string
dim sRet as string
with currentdb.openrecordset("select [" & fldName & "] from [" & tableName & "] where " & criteria & ";", dbOpensnapshot, dbReadonly)
    if not (.bof and .eof) then
        .movefirst
    end if
    do until .eof
        if not isnull(.fields(0)) then
            sRet = sRet & .fields(0) & "_"
        end if
        .movenext
    loop
end with
if len(sRet)<>0 then
    sRet = Left$(sRet, Len(sRet)-1)
end if
concatField = sRet
end function

on an unbound textbox on Report, set its ControlSource:

=concatField("theTableName","theFieldName")

For the output (pdf)

docmd.OutputTo acOutputReport,"yourReportName",acformatpdf, "pathOfOutput\" & me.unboundtextboxName & ".pdf"
 

georg0307

Registered User.
Local time
Today, 07:53
Joined
Sep 11, 2014
Messages
91
hHi,

sure I am wrong, at this point I give you my DB because it doesn't work well. it give me back in the textbox 2 numbers... 13 and 14.
 

Attachments

  • INBOUND_CHECK_LIST.zip
    749.8 KB · Views: 53

Gasman

Enthusiastic Amateur
Local time
Today, 06:53
Joined
Sep 21, 2011
Messages
14,350
Use the functions, if you cannot code.
theDBguy's is the simplest to use.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:53
Joined
May 7, 2009
Messages
19,247
see your report.
 

Attachments

  • INBOUND_CHECK_LIST.zip
    756.7 KB · Views: 64

georg0307

Registered User.
Local time
Today, 07:53
Joined
Sep 11, 2014
Messages
91
Ciao, ok I understood my error thank you very much!!! SOLVED
 

Users who are viewing this thread

Top Bottom