I am hoping that someone can assist me with a code problem.
Here is the history of the issue. We had a database that was created in Access 2003 the database had a module in it called Median:
Expand|Select|Wrap|Line Numbers
- Public Function MedianOfRst(RstName As String, Company_T As String, Company_V As String, State_T As String, State_V As String, Group_T As String, Group_V As String, Sub_Group_T As String, Sub_Group_V As String, Band_T As String, Amount_T As String) As Double
- 'This function will calculate the median of a recordset. The field must be a number value.
- Dim MedianTemp As Double
- Dim RstOrig As Recordset
- Set RstOrig = CurrentDb.OpenRecordset(RstName, dbOpenDynaset)
- RstOrig.Sort = Amount_T
- RstOrig.Filter = "[" & Company_T & "] = '" & Company_V & "' And [" & State_T & "] = '" & State_V & "' And [" & Group_T & "] = '" & Group_V & "' And [" & Sub_Group_T & "] = '" & Sub_Group_V & "' And [" & Band_T & "] > 'A'"
- Dim RstSorted As Recordset
- Set RstSorted = RstOrig.OpenRecordset
- If RstSorted.RecordCount <> 0 Then
- If RstSorted.RecordCount Mod 2 = 0 Then
- RstSorted.AbsolutePosition = (RstSorted.RecordCount / 2) - 1
- MedianTemp = RstSorted.Fields(Amount_T).Value
- RstSorted.MoveNext
- MedianTemp = MedianTemp + RstSorted.Fields(Amount_T).Value
- MedianTemp = MedianTemp / 2
- Else
- RstSorted.AbsolutePosition = (RstSorted.RecordCount - 1) / 2
- MedianTemp = RstSorted.Fields(Amount_T).Value
- End If
- Else
- MedianTemp = 0
- End If
- MedianOfRst = MedianTemp
- End Function
Since the creation of this database we have converted the database to the new file format (accdb) and are now running office 2010. It seems to have stopped working once we went to office 2010.
When we run the module it stops on the line of code:
Expand|Select|Wrap|Line Numbers
- Set RstSorted = RstOrig.openRecordset
Thank in advance for any help you can give me.
bwesenberg