Refering to an Access Field in VBA

Hello Experts:

I am trying to create an Access function to perform a calculation and would like to reduce the number or variables a user will have to assign when entering the function. Only the "forecast" variable changes and the rest stay the same. Is it possible to assign the remaining variables in the VBA code as opposed to entering them when entering the function. For example, I think it should look something like this:

set WAC = currentDb.table1.WAC

The function I have so far is posted below.

Function baseRebate(WAC, rebateBase, rebatePct, qtyDisp, numOfClaims, forecast, utilLICS, rateLICS, adminFee, priceProtPctInc, PP_BaseWac) As Double

'ignore errors

On Error Resume Next

'convert string fields into Double for calculations

rebatePct = CDbl(rebatePct)
qtyDisp = CDbl(qtyDisp)
numOfClaims = CDbl(numOfClaims)
forecast = CDbl(forecast)
utilLICS = CDbl(utilLICS)
rateLICS = CDbl(rateLICS)
adminFee = CDbl(adminFee)
priceProtPctInc = CDbl(priceProtPctInc)
PP_BaseWac = CDbl(PP_BaseWac)
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You could pass the function as recordset as opposed to passing it 12 variables.

Function baseRebate(ByVal rst as dao.recordset, forecast as string)

adminFee = CDbl(rst!adminFee)

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Build a Function that calls your Function:

Function CallMyFunction(vForecast As Double)
  baseRebate Function yourvariableshere
End Function

Your users will on need to supply the single "vForecast" variable.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.