I have found sample code on the web for calling an excel function (being new to Access I tend to borrow bits and pieces from anywhere and everywhere):
Expand|Select|Wrap|Line Numbers
- Function fXLCoupDayBS(dtmSettlement As Date, dtmMaturity As Date, frequency As Integer, basis As Integer) As Long
- ' Uses the XL function DAYS360 to return the number of days between 2 dates based on a 360 day year.
- ' Accepts:
- ' dtmStart - the start date
- ' dtmEnd - the end date
- ' blnMethod - whether to use the US or European Method in the calculation
- ' Returns:
- ' a string containing the converted number
- On Error GoTo E_Handle
- Dim objXL As Excel.Application
- Set objXL = CreateObject("Excel.Application")
- If IsMissing(blnMethod) Then blnMethod = False
- fXLCoupDayBS = objXL.WorksheetFunction.COUPDAYBS(dtmSettlement, dtmMaturity, frequency, basis)
- fExit:
- objXL.Quit
- Set objXL = Nothing
- Exit Function
- E_Handle:
- MsgBox Err.Description, vbOKOnly + vbCritical, "Error: " & Err.Number
- Resume fExit
- End Function
In short, I am not sure how to call a function from a query, passing in the arguments of the function from the query. Can anyone help? Again, if anyone can suggest a better method I am all ears!