Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Reports / Printing / January 2006

Tip: Looking for answers? Try searching our database.

Concatenating a field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AT - 12 Jan 2006 17:45 GMT
Here is the code I am using to concatenate ( I found this on a post here,
thanks!) a field in a report.  
   Dim db As DAO.Database
   Dim rs As DAO.Recordset
   Set db = CurrentDb
   Set rs = db.OpenRecordset(pstrSQL)

   With rs
       If Not .EOF Then
           .MoveFirst
           Do While Not .EOF
               strConcat = strConcat & _
               .Fields(0) & pstrDelim
               .MoveNext
           Loop
       End If
       .Close
   End With
   Set rs = Nothing
   If Len(strConcat) > 0 Then
       strConcat = Left(strConcat, _
       Len(strConcat) - Len(pstrDelim))
   End If
   Concatenate = strConcat
End Function

Here is the field I have in my query for the report
CName: Concatenate("SELECT [Container] FROM [tblContainer] WHERE
[ContainerID] =" & [SalesID])

This works great for most things I need to concatenate, however I have a
report that I want a little bit deeper.  I'm not very good at SQL type
statements so bear with me.  I want the cancatenate field to not only group
where the ContainerID = the SalesID, but then also show only the containers
that are in the sections I have listed in my report.  Like SalesID 1 shows
section 1, 2 & 3.  Right now, in section 1, 2, & 3 it shows ALL of the
containers for that SalesID.  I was wondering if there some sort of "AND"
statement that I could add to the end of the field in the query that would
concatenate it by the first group and then by the second and only show the
containers that go with each section.  Hope that makes sense!  

Thanks for any help you can give me.
Duane Hookom - 12 Jan 2006 17:54 GMT
I'm not sure I understand your tables/fields/report but you might be able to
CName: Concatenate("SELECT [Container] FROM [tblContainer] WHERE
[ContainerID] =" & [SalesID] & " AND [GroupID] = " & [GroupID])

Keep in mind that if GroupID is text, you would need something like:

CName: Concatenate("SELECT [Container] FROM [tblContainer] WHERE
[ContainerID] =" & [SalesID] & " AND [GroupID] = """ & [GroupID] & """")

Signature

Duane Hookom
MS Access MVP
--

> Here is the code I am using to concatenate ( I found this on a post here,
> thanks!) a field in a report.
[quoted text clipped - 40 lines]
>
> Thanks for any help you can give me.
AT - 12 Jan 2006 19:23 GMT
That worked great!  I had tried a few things, but didn't quite have the & "
AND in the right place.  Thanks much!

> I'm not sure I understand your tables/fields/report but you might be able to
> CName: Concatenate("SELECT [Container] FROM [tblContainer] WHERE
[quoted text clipped - 49 lines]
> >
> > Thanks for any help you can give me.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.