sr71aa
05-07-2007, 11:58 AM
Hello,
I seem to have a similiar problem to others and I tried to read through this forum, but I am not well versed in the code and I frankly find some of the explanations way to complicated. I was hoping someone can help me with a problem. I have data that looks like this:
Name Comments
J Smith 1/1/07-ATO
J Smith 1/10/07-UAU
S Smith 1/13/07-ATO
D Smith 1/2/07-OT
D SMith 1/3/07-OT
D Smith 1/4/07-ATO
I want it to look like this:
Name Comments
J Smith 1/1/07-ATO, 1/10/07-UAU
S SMith 1/13/07-ATO
D Smith 1/2/07-OT, 1/3/07-OT, 1/4/07-ATO
ANy suggestions?
Uncle Gizmo
05-07-2007, 04:33 PM
There's an example here showing you how to do something similar. (http://www.access-programmers.co.uk/forums/showthread.php?t=71302) There is also a sample database called --- FieldDataHorizontalyOnReport.zip
sr71aa
05-07-2007, 09:26 PM
Thanks! I really appreciate it. I looked at the example but I don't understand the fConList portion. It looked like a function, but when I try to duplicate it, I get an error. What exactly is fConList and how do I use it?
Uncle Gizmo
05-08-2007, 12:57 AM
fConList is a function specific to my project, it is unlikely that you will be able to use it as it is. The significant part of the function, the bit that you could use in your own function is this bit:
Set RS = DB.OpenRecordset(strSQL, dbOpenForwardOnly)
Do Until RS.EOF
If strText = "" Then 'This If statment prevents a single comma at the begining of the text","
strText = RS!RepairDesc
Else
strText = strText & ", " & RS!RepairDesc
End If
RS.MoveNext
Loop
This takes the description of the of each repair made to the unit and returns them in a string.
Uncle Gizmo
05-08-2007, 01:04 AM
First you should create an SQL statement that returns just one of your customer names from your list:
Name Comments
J Smith 1/1/07-ATO
J Smith 1/10/07-UAU
S Smith 1/13/07-ATO
D Smith 1/2/07-OT
D SMith 1/3/07-OT
D Smith 1/4/07-ATO
Your SQL statement should return the following for customer "D Smith"
D Smith 1/2/07-OT
D SMith 1/3/07-OT
D Smith 1/4/07-ATO
Put the SQL statement in here:
Set RS = DB.OpenRecordset(strSQL, dbOpenForwardOnly)
---- at this point >>> "strSQL" (you can use a string variable as shown, or the actual SQL statement)
You will need to change the name here:
strText = RS!RepairDesc
as "RepairDesc" refers to a field returned by the Example SQL statement, and you have a new SQL statement so you need to identify which field you want to extract information from.