Concantenate vertical information

D

Di

Hello,

Can anyone tell me how I can concantenate VERTICAL
information?

For example I have a table of Customer IDs. Each Customer
ID can have several Product IDs.

I need the user to be able to view each Customer ID as one
row of information down the length of the page, while
viewing all of its Product IDs as comma delimited
information in the same row as its Customer ID.

Hope this makes sense and thanks for your help!!!

Di
 
T

Ted Allen

Hi Di,

I use a custom function to do this. Just create a new
module, go to Insert|Procedure from the menu and choose
Function and type the name of your function.

Then, in the parenthesis of your function type a name of
the variable(s) that you want to receive any passed
values (CustomerID in your case). Finally, write the
code to generate the function value from the passed
values.

After you have defined your function, you can call it
from queries, forms and reports as if it were a built in
function (although it will be listed under the db name in
the expression builder rather than built-in functions).
To call the function from your form (or the form's query
source) you would just type the function name and pass
the value of the CustID field such as:

=ProdIDList([CustID])

An example of a function that I use to build a string of
the Council Districts that a Project is in is listed
below (watch the wrapping):

Public Function CDList_byProjID(ProjID As Integer)
Dim dbs As Database, rstReadCDTable As Recordset
Set dbs = CurrentDb
StrSql = "SELECT * FROM tzlinkCouncilDist WHERE [Proj ID
Ref]= " & ProjID
Set rstReadCDTable = dbs.OpenRecordset(StrSql,
dbOpenSnapshot)
With rstReadCDTable
If .BOF = True Then
CDList_byProjID = Null
Exit Function
Else
If ![Council ID Ref] = 16 Then
CDList_byProjID = "ALL"
Exit Function
Else
CDList_byProjID = ![Council ID Ref]
End If
End If
.MoveNext
Do While Not .EOF
If ![Council ID Ref] = 16 Then
CDList_byProjID = "ALL"
Exit Function
Else
CDList_byProjID = CDList_byProjID & ", "
& ![Council ID Ref]
End If
.MoveNext
Loop
End With
End Function


Hope that helps.

-Ted Allen
 
D

Di

Thank you Ted!!

Di

-----Original Message-----
Hi Di,

I use a custom function to do this. Just create a new
module, go to Insert|Procedure from the menu and choose
Function and type the name of your function.

Then, in the parenthesis of your function type a name of
the variable(s) that you want to receive any passed
values (CustomerID in your case). Finally, write the
code to generate the function value from the passed
values.

After you have defined your function, you can call it
from queries, forms and reports as if it were a built in
function (although it will be listed under the db name in
the expression builder rather than built-in functions).
To call the function from your form (or the form's query
source) you would just type the function name and pass
the value of the CustID field such as:

=ProdIDList([CustID])

An example of a function that I use to build a string of
the Council Districts that a Project is in is listed
below (watch the wrapping):

Public Function CDList_byProjID(ProjID As Integer)
Dim dbs As Database, rstReadCDTable As Recordset
Set dbs = CurrentDb
StrSql = "SELECT * FROM tzlinkCouncilDist WHERE [Proj ID
Ref]= " & ProjID
Set rstReadCDTable = dbs.OpenRecordset(StrSql,
dbOpenSnapshot)
With rstReadCDTable
If .BOF = True Then
CDList_byProjID = Null
Exit Function
Else
If ![Council ID Ref] = 16 Then
CDList_byProjID = "ALL"
Exit Function
Else
CDList_byProjID = ![Council ID Ref]
End If
End If
.MoveNext
Do While Not .EOF
If ![Council ID Ref] = 16 Then
CDList_byProjID = "ALL"
Exit Function
Else
CDList_byProjID = CDList_byProjID & ", "
& ![Council ID Ref]
End If
.MoveNext
Loop
End With
End Function


Hope that helps.

-Ted Allen
-----Original Message-----
Hello,

Can anyone tell me how I can concantenate VERTICAL
information?

For example I have a table of Customer IDs. Each Customer
ID can have several Product IDs.

I need the user to be able to view each Customer ID as one
row of information down the length of the page, while
viewing all of its Product IDs as comma delimited
information in the same row as its Customer ID.

Hope this makes sense and thanks for your help!!!

Di
.
.
 
D

Duane Hookom

This code is good for a single usage. There is a generic concatenate
function and demo at
http://www.rogersaccesslibrary.com/OtherLibraries.asp#Hookom,Duane.

--
Duane Hookom
MS Access MVP


Di said:
Thank you Ted!!

Di

-----Original Message-----
Hi Di,

I use a custom function to do this. Just create a new
module, go to Insert|Procedure from the menu and choose
Function and type the name of your function.

Then, in the parenthesis of your function type a name of
the variable(s) that you want to receive any passed
values (CustomerID in your case). Finally, write the
code to generate the function value from the passed
values.

After you have defined your function, you can call it
from queries, forms and reports as if it were a built in
function (although it will be listed under the db name in
the expression builder rather than built-in functions).
To call the function from your form (or the form's query
source) you would just type the function name and pass
the value of the CustID field such as:

=ProdIDList([CustID])

An example of a function that I use to build a string of
the Council Districts that a Project is in is listed
below (watch the wrapping):

Public Function CDList_byProjID(ProjID As Integer)
Dim dbs As Database, rstReadCDTable As Recordset
Set dbs = CurrentDb
StrSql = "SELECT * FROM tzlinkCouncilDist WHERE [Proj ID
Ref]= " & ProjID
Set rstReadCDTable = dbs.OpenRecordset(StrSql,
dbOpenSnapshot)
With rstReadCDTable
If .BOF = True Then
CDList_byProjID = Null
Exit Function
Else
If ![Council ID Ref] = 16 Then
CDList_byProjID = "ALL"
Exit Function
Else
CDList_byProjID = ![Council ID Ref]
End If
End If
.MoveNext
Do While Not .EOF
If ![Council ID Ref] = 16 Then
CDList_byProjID = "ALL"
Exit Function
Else
CDList_byProjID = CDList_byProjID & ", "
& ![Council ID Ref]
End If
.MoveNext
Loop
End With
End Function


Hope that helps.

-Ted Allen
-----Original Message-----
Hello,

Can anyone tell me how I can concantenate VERTICAL
information?

For example I have a table of Customer IDs. Each Customer
ID can have several Product IDs.

I need the user to be able to view each Customer ID as one
row of information down the length of the page, while
viewing all of its Product IDs as comma delimited
information in the same row as its Customer ID.

Hope this makes sense and thanks for your help!!!

Di
.
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top