473,466 Members | 1,372 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Upgrading Access Database to 2007 issue

2 New Member
I am have upgraded my Access database to 2007. It is working fine with the exception of code which imports specific fields out of an excel file into several tables in the database.

This worked fine in 2003 but after the upgrade, I get a 'Compile - Method or Data Member not found'

I am sure there is an easy solution and would like some help. The code is below:

Expand|Select|Wrap|Line Numbers
  1. Private Sub b1_Click()
  2.   On Error GoTo e1
  3.  
  4.   Me!zz = Null
  5.  
  6.   'ensure the zip file is not being modified
  7.   Set fso = New FileSystemObject
  8.  
  9.   hold_import_path = "Q:\Biz\Administration\File Exports Imports\"
  10.   hold_import_name = "Base Report for All.xlsx"
  11.  
  12.   If Not fso.FileExists(hold_import_path & hold_import_name) Then
  13.      mess = "Sorry I cannot find the file"
  14.      mess = mess & crlf & crlf & hold_import_path & hold_import_name
  15.      MsgBox mess, 0, "File not found"
  16.      Set fso = Nothing
  17.      Exit Sub
  18.   End If
  19.   Set fso = Nothing
  20.  
  21.   'open the excel sheet
  22.   Set xlapp = New Excel.Application
  23.   Set xlworkbook = xlapp.Workbooks.Open(hold_import_path & hold_import_name)
  24.   Set xlworksheet = xlworkbook.Worksheets(1)   '("sheet_name")
  25.   screen_pos = 2   'position on excel sheet to start reading
  26.  
  27.   While Len(xlworksheet.Range("a" & Format(screen_pos))) > 0
  28.     hold = xlworksheet.Range("a" & Format(screen_pos))
  29.     If IsNumeric(hold) Then
  30.        '[Employee_PVE] table
  31.        hold_crit = "select * from [Employee_PVE] where [Employee_PVE].[Emp Id] = " & CLng(hold)
  32.        Set curr_rs = curr_db.OpenRecordset(hold_crit)
  33.        If curr_rs.RecordCount > 0 Then
  34.           curr_rs.Edit
  35.        End If
  36.        If curr_rs.RecordCount = 0 Then
  37.           curr_rs.AddNew
  38.           curr_rs![Emp ID] = xlworksheet.Range("a" & Format(screen_pos))
  39.        End If
  40.        curr_rs![Name] = xlworksheet.Range("b" & Format(screen_pos))
  41.        curr_rs![Division] = xlworksheet.Range("c" & Format(screen_pos))
  42.        curr_rs![Team] = xlworksheet.Range("d" & Format(screen_pos))
  43.        curr_rs![Location] = xlworksheet.Range("e" & Format(screen_pos))
  44.        curr_rs![Occupational Category] = xlworksheet.Range("f" & Format(screen_pos))
  45.        curr_rs![Gender] = xlworksheet.Range("g" & Format(screen_pos))
  46.        curr_rs![Date Started] = xlworksheet.Range("h" & Format(screen_pos))
  47.      curr_rs.Update
  48.        curr_rs.Close
  49.  
Jan 10 '12 #1
5 1688
Stewart Ross
2,545 Recognized Expert Moderator Specialist
In the VBA IDE window check that the library references include the Microsoft Scripting Runtime (used for variable fso, a FileSystemObject) and the Microsoft Excel 12.0 library (used by the xlApp Excel application variable and the other Excel-related variables in the sub).

Select Tools, References from the VBA IDE menu and ensure that these two libraries are ticked.

It would be helpful to know which line is throwing the error if you find continued problems.

-Stewart
Jan 10 '12 #2
NeoPa
32,556 Recognized Expert Moderator MVP
Please see When Posting (VBA or SQL) Code. Posting questions properly helps save your time as well as ours. You will find there some hints that will not only help with posting but may also help you generally.

Another link that might prove useful for this question is Converting to Access 2007 or 2010.

Good luck :-)
Jan 10 '12 #3
mtm70
2 New Member
Hi Guys,

Thanks for your help.

Unfortunately, these libraries were already ticked on.

The line that it errors out on is [curr_rs.Edit].

Any other ideas?
Jan 10 '12 #4
NeoPa
32,556 Recognized Expert Moderator MVP
I take that to mean your error occurs on line #34. It's easier to specify it that way, and easier to find obviously. It's one of the benefits of using the [ CODE ] tags when posting code. All concerned benefit.

PS. What did you find when you checked the second article linked in my earlier post? It generally helps to comment on what you find that's relevant, so as to ensure we all know what you've discovered. Otherwise it seems a little like you didn't even check (which, of course, would effect our attitude when dealing with you in future). I'm sure you appreciate why it makes sense to comment on what is posted.
Jan 10 '12 #5
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Your sub does not have Dim statements for any of the variables concerned. Either they are not being explicitly defined (which is not good practice) or they are global to the code module in which the sub is located (again, not good practice).

I would suggest you should explicitly define all the variables within the sub itself. If you place an Option Explicit directive at the top of your module then compile the module the VBA IDE will identify for you all instances of undeclared variables within the module.

The point of this is that there is more than one kind of recordset available in Access - DAO (which is the built-in recordset type) and ADO. They have different methods and modes of use.

To ensure that your VBA sub is using the correct type of recordset (DAO in this case), place the following declaration statement after the header line of your sub:

Expand|Select|Wrap|Line Numbers
  1. Dim curr_rs as DAO.Recordset
This at least will rule out the variable type as the source of your error.

-Stewart
Jan 11 '12 #6

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

Similar topics

0
by: Bob | last post by:
How can I copy query objects from one MS Access database to another using VB.net. Both databases are on the same computer. As I create a report using vb.net, I create and reference queries in a...
38
by: kavsak | last post by:
Hi. Not sure that this is the right place to ask but here goes. I have an application based on access97 and VB6 which I need to upgrade. It has to handle up to 20 concurrent users on a Win2k...
23
by: Bosnoval | last post by:
Access 2003 Databse ASP.NET 2 Win 2003 Server Currently I have a search page that only allows a single keyword (person) to be searched at a time. I thought upgrading that option via a multiple...
4
by: gpl666666 | last post by:
Does anyone know any free online space which allows user to upload mdb Access database file?
1
by: nosipho | last post by:
Hi guys, I want to upgrade to Office 2003/ 2007 Pro, currently I'm using Office 2000. the problem is I have an Access database which I'm not sure if I'll be able to access it with Office 2003/...
9
by: sheri | last post by:
Hi need your expert advice. I want to put my access database online so different users in my company can use it. I can put in on a secure directory on my website. Can you direct me the best way...
1
by: vbace2 | last post by:
I have searched this forum, and the web, and I have not been able to find a solution to my issue. I may not have used the right search information to find the answer, but I found a lot of issues...
5
by: Bobby | last post by:
Hi, I have an application which is written in Access 2003, with a SQL server 2000 back end. The application uses a lot of VBA, as well as quite a few macros. We are about to upgrade to Office...
3
by: kgudgel | last post by:
I am relatively new to the replication process in Access. My issue is that I have a Design Master and one replica. End users have been using the replica and adding data to the tables. I recently...
3
by: damola | last post by:
Good day everyone Please how can i prevent access to certain forms in ms access database 2007. i want it to be in such a way that when i enter user login,it automatically detects the forms the user...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
1
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.