3

I'm trying to create a report in Access 2003 that lists all children for each individual in a single concatenated string. Allen Browne's ConcatRelated() looked promising.

So I copied the code into a module, compiled it from the debug menu (nothing happened) and made a query:

SELECT Moms.MomID, Moms.MomLast, ConcatRelated("KidFirst","Kids","MomID =" & Kids.MomID)
FROM Kids INNER JOIN Moms ON Kids.MomID = Moms.MomID;

And I get an error that says "Undefined function 'Concatrelated' in expression.

What has gone wrong? The only place I deviated from the directions was to type "ConcatRelated" in the module name.

davidkonrad
  • 83,997
  • 17
  • 205
  • 265
QtheNovice
  • 95
  • 3
  • 13

1 Answers1

4

Do not call the Module the same as the function, it can sometimes make things confusing for VBA.
Rename the module something like "DatabaseUtils" for instance.

Make sure the function is really defined as Public Function ConcatRelated(..., the Public here is important, otherwise the function will not be visible outside the module itself.

Renaud Bompuis
  • 16,596
  • 4
  • 56
  • 86
  • I figured it out quite late last night and it's working now. I'd never created/named a module before. The rest of the function is exactly as written by Allen Browne, so it is `Public Function...` – QtheNovice Sep 23 '13 at 15:53