Use Excel function in Access

M

Mike Collard

I have a form with three unbound text boxes that will each
contain a value; the controls are named P1, P2 and P3
There is a fourth box that should contain the minimum
value of the three boxes so I thought I would try and use
the Excel Min function thus:

Function fXLMin(ParamArray Values()) As Variant

Dim objXL As Excel.Application

On Error GoTo Error_Handler

Set objXL = CreateObject("Excel.Application")

fXLMin = objXL.WorksheetFunction.Min(Values)

fExit:
Exit Function
Error_Handler:
MsgBox Err.Description, vbOKOnly +
vbCritical, "Error: " & Err.Number
Resume fExit
End Function

*******************************************
The form has a Confirm button with an On_click event that
calls the Min Function thus: Min([P1],[P2],[P3])

Nothing happens when I click the Confirm button and no
error is displayed.

Any ideas?

Thanks

Mike Collard
 
Top