Question : How do I use a user-defined function in Access

I'm creating a query in Access that is converting the month name in a field to it's number equivalent.  I'd like to create a custom function such as ConvertMonthName() and then call it in my query field row.  Is there a way to do that.  I'm learning how to do this type of thing in Excel, but don't know if it's possible in Access.

Answer : How do I use a user-defined function in Access

Yes.

Create your custom Function in a Module ... do not name the Module the same name as the Function.

Then ... in your query ... create an Expression for a Field Name like so

MyFx:ConvertMonthName()

Your Function might look like this:

Public Function ConvertMonthName()

   ' some code

ConvertMonthName =  ' this passes the result back to the query

End Function

mx
Random Solutions  
 
programming4us programming4us