By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,154 Members | 1,050 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,154 IT Pros & Developers. It's quick & easy.

How fix code from access 2003 that no longer works in access 2010?

P: n/a
Good Morning,
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
  1. 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
  2.      'This function will calculate the median of a recordset. The field must be a number value.
  3.      Dim MedianTemp As Double
  4.      Dim RstOrig As Recordset
  5.      Set RstOrig = CurrentDb.OpenRecordset(RstName, dbOpenDynaset)
  6.      RstOrig.Sort = Amount_T
  7.      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'"
  8.      Dim RstSorted As Recordset
  9.      Set RstSorted = RstOrig.OpenRecordset
  10.      If RstSorted.RecordCount <> 0 Then
  11.         If RstSorted.RecordCount Mod 2 = 0 Then
  12.              RstSorted.AbsolutePosition = (RstSorted.RecordCount / 2) - 1
  13.              MedianTemp = RstSorted.Fields(Amount_T).Value
  14.              RstSorted.MoveNext
  15.              MedianTemp = MedianTemp + RstSorted.Fields(Amount_T).Value
  16.              MedianTemp = MedianTemp / 2
  17.         Else
  18.              RstSorted.AbsolutePosition = (RstSorted.RecordCount - 1) / 2
  19.              MedianTemp = RstSorted.Fields(Amount_T).Value
  20.         End If
  21.      Else
  22.         MedianTemp = 0
  23.      End If
  24.      MedianOfRst = MedianTemp
  25. 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
  1. Set RstSorted = RstOrig.openRecordset
We did a little research and found that office 2010 no longer supports this code. Can anyone help me to re write this code so we can fix the database?

Thank in advance for any help you can give me.

bwesenberg
Nov 22 '10 #1
Share this Question
Share on Google+
1 Reply


dsatino
100+
P: 393
You might try checking to see if you're simply missing library reference and reconnect it.

Open the vba code window, go to tools/references and see if anything says "Missing Ref" or something of that nature.
Nov 22 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.