Converting Numbers to text for check writing

Discuss the database features

Converting Numbers to text for check writing

Postby TJM05 » Mon Jan 28, 2013 11:01 pm

Hello All,
I am attempting to print out my own checks using the information I keep in Base. So currently I have a form with a table control that shows vendor name, amount the check needs to be written for, etc. I am making good progress on everything except for getting a macro to automatically convert a field of numbers (the amount to pay) into a field of text (i.e. $300.00 to three hundred dollars and zero cents)
I found this code for converting numbers into text dollars (it is for a specific amount 4234.07)

Code: Select all   Expand viewCollapse view
Sub Main
   Print NumToDollars( 4234.07 )
End Sub


Function NumToDollars( ByVal nNumber As Double ) As String
   cWords = ""
   
   nDollars = Int( nNumber )
   nCents = Int( (nNumber - Int( nNumber ) + 0.005) * 100 )
   
   cDollars = NumToWords( nDollars )
   cCents = CSTR( nCents )
   If Len( cCents ) < 2 Then
      cCents = "0" & cCents
   EndIf
   
   cWords = cDollars & " Dollars and " & cCents & " Cents"
   
   NumToDollars() = cWords
End Function


But I have having trouble applying it to my application. What I would like to do is have a macro that reads the amount to be paid on a certain line of the table, converts it into text dollars (as the code above does) and then places the result in another field which I can then include on the writer document that will be formatted like a check. I am OK with figuring out the formatting, etc... its just this code that I am struggling with. Any help would be greatly appreciated.
Thanks!
TJM05
Open Office 3.3/Windows 7
TJM05
 
Posts: 25
Joined: Tue May 10, 2011 10:58 pm

Re: Converting Numbers to text for check writing

Postby Arineckaig » Tue Jan 29, 2013 12:26 pm

But I have having trouble applying it to my application. What I would like to do is have a macro that reads the amount to be paid on a certain line of the table, converts it into text dollars (as the code above does) and then places the result in another field which I can then include on the writer document that will be formatted like a check


Debugging how an application makes use of a macro is difficult without an example of that particular application. If it should be of any help an example file for AOO Base set up to record and print UK cheques can be downloaded from http://dl.dropbox.com/u/10552709/ChequePrinting.odb. Your print layout will, of course, differ from that required for UK cheques but hopefully this example may offer some pointers. The key macro is triggered by the 'Execute action' event of 'Fill cheque' button on the 'BankOfScotland New Cheque' form document.
When this issue has been resolved, it would help other users of the forum if you add the word - [Solved] - to the Subject line of your 1st post (edit button top right).
OOo 3.4.1 on MS Windows XP MySQL and HSQLDB
Arineckaig
Volunteer
 
Posts: 600
Joined: Fri Nov 30, 2007 10:58 am
Location: Scotland

Re: Converting Numbers to text for check writing

Postby TJM05 » Tue Jan 29, 2013 6:19 pm

Thanks Arineckaig. I will take a look at this and let you know how i make out. At first glance this looks very promising.
Open Office 3.3/Windows 7
TJM05
 
Posts: 25
Joined: Tue May 10, 2011 10:58 pm


Return to Base

Who is online

Users browsing this forum: No registered users and 3 guests