ACC95: Missing Variable Declarations in Rate Function ExampleLast reviewed: August 29, 1997Article ID: Q160504 |
The information in this article applies to:
SYMPTOMSModerate: Requires basic macro, coding, and interoperability skills. When you use the example procedure in the Rate Function Help topic, you receive the following error message:
Variable not definedThis article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to the "Building Applications with Microsoft Access for Windows 95" manual.
CAUSEThe Rate function example does not dimension a number of the variables it uses. If you type Option Explicit in the Declarations section of the module in which you are using the Rate function example, the code does not compile because all variables have not been declared.
RESOLUTIONAdd the following line of code following the Constant declaration in the example:
Dim Fmt, FVal, Guess, PVal, Payment, TotPmts, PayType, APRThe modified example looks as follows:
Const ENDPERIOD = 0, BEGINPERIOD = 1 ' When payments are made. Dim Fmt, FVal, Guess, PVal, Payment, TotPmts, PayType, APR Fmt = "##0.00" ' Define percentage format. FVal = 0 ' Usually 0 for a loan. Guess = 0.1 ' Guess of 10 percent. PVal = InputBox("How much did you borrow?") Payment = InputBox("What's your monthly payment?") TotPmts = InputBox("How many monthly payments do you have to make?") PayType = MsgBox("Do you make payments at the end of the month?", _ vbYesNo) If PayType = vbNo Then PayType = BEGINPERIOD Else PayType = ENDPERIOD APR = (Rate(TotPmts, -Payment, PVal, FVal, PayType, Guess) * 12) * 100 MsgBox "Your interest rate is " & Format(CInt(APR), Fmt) & " percent." MORE INFORMATION
Steps to Reproduce Behavior
Keywords : DcmHlp kberrmsg PgmDecl SynFnc Version : 7.0 Platform : WINDOWS Hardware : x86 Issue type : kbdocerr |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |