How to Declare Names of Query Fields?

L

Leslie Coover

When using functions to calculate values based on field values in a query is
it neccessary to declare each query field in each function, or can they be
declared as public variables?

For example, must I do the following?

Function DiscRate(Purchase_Price As Currency, Pro_Cur_Val As Currency,
DateDifference As Double, Type As String, SumOfCashFlow As Currency,
Coupon As Double, M As Double)
<<code goes here>>
End Function

Function LowMFrate (Purchase_Price As Currency, Pro_Cur_Val As Currency)
<<code goes here>>
End Function

Or, can I do the following?

Option Compare Database
Option Explicit
Dim Purchase_Price As Currency
Dim Pro_Cur_Price As Currency
Dim DateDifference As Double
Dim Type As String
Dim SumOfCashFlow As Currency
Dim Coupon As Double
Dim M As Double

Function DiscRate ()
<<code goes here>>
End Function

Function LowMFrate
<<code goes here>>
End Function

Remember the names I am declaring are the names of fields in a query
(the place where I get the data to use in calculations)

Thanks!!!
 
M

Marshall Barton

Leslie said:
When using functions to calculate values based on field values in a query is
it neccessary to declare each query field in each function, or can they be
declared as public variables?

For example, must I do the following?

Function DiscRate(Purchase_Price As Currency, Pro_Cur_Val As Currency,
DateDifference As Double, Type As String, SumOfCashFlow As Currency,
Coupon As Double, M As Double)
<<code goes here>>
End Function

Function LowMFrate (Purchase_Price As Currency, Pro_Cur_Val As Currency)
<<code goes here>>
End Function

Or, can I do the following?

Option Compare Database
Option Explicit
Dim Purchase_Price As Currency
Dim Pro_Cur_Price As Currency
Dim DateDifference As Double
Dim Type As String
Dim SumOfCashFlow As Currency
Dim Coupon As Double
Dim M As Double

Function DiscRate ()
<<code goes here>>
End Function

Function LowMFrate
<<code goes here>>
End Function


Each function must declare its own arguments, but the
function's argument names have nothing to do with the query
field names (except in your mind, which is not at all bad).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top