Friday 17 July 2020

Call a custom VBA function from a query

Is is possible to call a custom VB function, saved in the same Access Db, from a query written in that db, and if so, how?


Answers:


Yes, you can call a macro or function from an Access query. Make your function public. Then call it inside your SQL like so:

 CustomFunction([field])

Answers:


Ok, here's the deal, Paul W.

I was trying to get this done before I asked the question and, upon reflection (not the .NET kind!) I think my question could have used a bit more elaboration.

When you answered (and I think your answer could have used a bit more elaboration too) it didn't seem different from what I'd tried, so I looked at my code again. I found a stupid bug that was preventing me from getting the result I was looking for. I've fixed it and everything's fine now.

So, in the end, I didn't ask the question that was really bothering me, and therefore you didn't give me the solution I was looking for. However, you did cause me to find the solution so I'd like to give you your props. However, I apparently don't have enough reputation (yet) to accept your answer or comment on it, so this reply will have to do. (I keep clicking on the checkmark but nothing happens.)


Answers:


No comments:

Post a Comment