B
Brad
Thanks for taking the time to read my question.
I am defining an array at the start of my Function. My problem is telling
Access how many compartments to reserve, it's a floating number. I tried
making a variable but the error msg I'm getting says I need a static number.
Is there a way around this?
Brad
Here is my code. I thought that I could use Excels ability to calculate
Median instead of reprogramming this. If it's harder to do this than
reprogram it, please let me know.
Function GetMedian()
Dim rst As DAO.Recordset
Dim dbs As DAO.Database
Dim objExcel As Object
Dim x As Integer
Dim NumOfRec As Integer
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tbl_Results")
NumOfRec = rst.RecordCount
Set objExcel = CreateObject("Excel.Application")
Dim dblData(NumOfRec) As Double
rst.MoveFirst
x = 0
Do Until rst.EOF
dblData(x) = rst!Protein
x = x + 1
Loop
GetMedian = objExcel.WorkSheetFunction.Median(dblData)
rst.Close
Set rst = Nothing
Set objExcel = Nothing
End Function
I am defining an array at the start of my Function. My problem is telling
Access how many compartments to reserve, it's a floating number. I tried
making a variable but the error msg I'm getting says I need a static number.
Is there a way around this?
Brad
Here is my code. I thought that I could use Excels ability to calculate
Median instead of reprogramming this. If it's harder to do this than
reprogram it, please let me know.
Function GetMedian()
Dim rst As DAO.Recordset
Dim dbs As DAO.Database
Dim objExcel As Object
Dim x As Integer
Dim NumOfRec As Integer
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tbl_Results")
NumOfRec = rst.RecordCount
Set objExcel = CreateObject("Excel.Application")
Dim dblData(NumOfRec) As Double
rst.MoveFirst
x = 0
Do Until rst.EOF
dblData(x) = rst!Protein
x = x + 1
Loop
GetMedian = objExcel.WorkSheetFunction.Median(dblData)
rst.Close
Set rst = Nothing
Set objExcel = Nothing
End Function