Function Variables

F

Forrest

How would one replace the string of numbers in the
following code with a field reference to an Access table?

The following code excerpt is from:
http://support.microsoft.com/default.aspx?scid=kb;EN-
GB;q198571


Sub xlMedian()
Dim objExcel As Excel.Application
Set objExcel = CreateObject("Excel.Application")
MsgBox objExcel.Application.Median(1, 2, 5, 8, 12, 13)
objExcel.Quit
Set objExcel = Nothing
End Sub

The following modification addresses the first record. I
need the median of all records.

Private Sub xlMedian_Click()
Dim objExcel As Excel.Application
Dim dbs As Database
Dim rst As Recordset
Set objExcel = CreateObject("Excel.Application")
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Investments")
MsgBox objExcel.Application.WorksheetFunction.Median
(rst![Amount])
objExcel.Quit
Set objExcel = Nothing

End Sub
 
S

SA

Forrest:

You don't have to use Excel to get a median in Access. Stop by our web and
look in the Code and Design Tips area under Queries for a function that you
can easily import into your db to use with a table or recordset to determine
medians or percentiles.

HTH
 

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