How To Convert Numbers To Words: Access VBA Function
Once again, I’ve been asked by a client to create procedure to turn a monetary number (numerical value) into its text equivalent and so I wanted to share with you how to convert numbers to words using Visual Basic code that can also be applied not just to your Access database but with any application that entertains VBA code!
How To Convert Numbers To Words: The Steps
This article is intended for users who know and have some VBA code knowledge but need a little push to see how an Access function can be called into your database application via a query, form or report to name a few objects.
Start by creating a new module in your visual basic editor screen or via the new module section from your Navigation pane window and save it with a useful name like ‘mod_MyFunctions‘.
Now to save time working out how to create the code and their logical workflows, you may wish to copy the SpellNumber VBA function.
Compile and save your module and you are now ready to use the custom function.
For example, I could create a query to express the ‘Order Amount‘ values into a text narrative by calling the ‘SpellNumber‘ function.
In my query below, I have added a calculated field next to ‘Order Amount‘ which calls the SpellNumber function with the following arguments completed:
Spell The Order Amount: SpellNumber([Order Amount],”GBP”)
Now run your query and the VBA function will handle and return any real numbers into text form using the ‘Order Amount‘ field:I created some flexibility where you can specify a currency of your choice by adding three commonly used country codes (GBP, USD and EUR). Of course, you can modify the code to add your own additional currencies too.
To understand the code will be down to your own knowledge of VBA code but I can help you learn how to programme in Access and how to convert numbers to words function works.