Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way to run a macro (UDF) as part of the SQL select?

Status
Not open for further replies.

BugZap13

Programmer
Dec 2, 2013
30
US
I m looking for a way to string together report codes for a contact. There may be many report codes for the contact. I have been working with too many databases which have ways to do this but can't seem to find the way in access. This is probably obvious to someone working with access a lot.

Contacts Table
ContactID LastName
Contact_1 Williams
Contact_2 Smithace

ReportCodes Table
ContactID Report Code
Contact_1 NL
Contact_1 WE
Contact_1 DN
Contact_2 WE
Contact_2 DN

Want a result like:
ContactID LastName ReportCodeList
Contact_1 Williams NL,WE,DN
Contact_2 Smithace WE,DN

SELECT contact.ContactID, contact.LastName, something(contact.ContactID) AS ReportCodeList
FROM contact
RIGHT JOIN reportcodes ON reportcodes.contactID = contact.contactID

Any suggestions to get me on the right track would be appreciated.
 
Please, use "Great post? Star it!" link to mark the helpful post.
That also helps others to see which answer was 'the one' :)

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top