Haven't read your code - only the initial post.
You cannot use a public funtion created in an MS ACCESS module in a "query" called from VB.
You will need to try to accomplish this using Jet VBA functions such as:
IIF(), Mid(), Left(), InStr(). etc. - however, not portable to other Dbm-systems...