473,414 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

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

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
1 2030
dsatino
393 256MB
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

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

Similar topics

3
by: Justin Koivisto | last post by:
OK, here's one of the rare times where I call out to all of you. ;) I need to implement a promotional discount code module into osCommerce 2.2 Milestone 2. I've never created an OSC module...
2
by: Dutchy | last post by:
Hi there, After spending several hours trying all I could imagine and search for in Google I gave up. In a continuous form I want to sort the choosen column by clicking the header (label) of...
2
by: Thelma Lubkin | last post by:
I do a lot of my code writing for Access forms at home, where I have no access to Access. While in Access, I export the entire primary code module, xxx.cls where xxx begins "Frm_" and includes...
3
by: Salad | last post by:
I'm asking this for curiosity's sake. Is there a code module size limit? I looked at Access Specifications in help and didn't notice a code limit size. For some odd reason I was under the...
1
by: phill86 | last post by:
Hi, I have an access 2010 database that I want to convert to an SQL Server database and I need to know if the data macros in access will still work in the SQL database or will i have to create...
5
by: jaad | last post by:
Hello, I have a database that was written in access 2007 on my pc. I wanted to work off site with the database so I uploaded it onto my laptop which is loaded with access 2010 beta. When I...
2
by: sierra7 | last post by:
It seems Access 2010 is associating an 'input mask' or field type with a combo box when a form is opened, even though there is no Format setting on the control. I have a form which has been...
0
by: Alisha Harris | last post by:
I have a form that also contains a subform. I have tried to input Allen Browne's code to have the last records entered on the form to carry over when a new record is added. However, nothing is...
1
by: Hal Kaelin | last post by:
Compile Error Ambiguous name detected: OpenReferenceDocument See attached file Private Sub lstRecapFileList_DblClick(Cancel As Integer) Call OpenReferenceDocument(RecapFolder &...
2
by: dougancil | last post by:
I have a user who had deleted some records from a database today using Access 2010. They have an ID field that's autonumbered. They have No Duplicates allowed. When they created a new record today,...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.