473,503 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with SQLPassthrough in Access 2007 using DAO: Invalid database object referen

1 New Member
Problem with SQLPassthrough in Access 2007 using DAO

I have this piece of VBA code from inside Access to retrieve data from external database (SQL or Oracle)

Expand|Select|Wrap|Line Numbers
  1.     sConn = "ODBC;DSN=ABC;UID=XYZ;PWD=123;"
  2.     sSQL = "SELECT * FROM BLAG WHERE UPPER(id) = UPPER('12aBxY')"
  3.  
  4.     Set db = DBEngine.Workspaces(0).OpenDatabase("", False, False, sConn)    
  5.     Set rs = db.OpenRecordset(sSQL, dbOpenForwardOnly, dbSQLPassThrough)
  6.  
This works fine with all previous versions of Access. In 2007, I got this error "Invalid database object reference"

Have Been Google for 3 days with no luck. Any suggestion?
Jan 30 '08 #1
1 2563
MMcCarthy
14,534 Recognized Expert Moderator MVP
I haven't used 2007 much but I have heard rumours that MS is phasing out odbc. You could try the following ADO code which means you won't need the pass through query.

Expand|Select|Wrap|Line Numbers
  1. 'Defining variables
  2. Dim cnn As ADODB.Connection
  3. Dim rsy As ADODB.Recordset
  4. Dim db_name As String
  5. Dim UserName As String
  6. Dim Password As String
  7.  
  8.     Set cnn = New ADODB.Connection
  9.     Set rst = New ADODB.Recordset
  10.  
  11.     db_name = "KRIJGS"
  12.     UserName = "bertuser"
  13.     Password = "abcxyz123"
  14.  
  15.     'Making an ODBC connection according to ADO
  16.     cnn.Open "DSN=" + db_name + ";UID=" + UserName + ";PWD=" _
  17.     & Password + ";"
  18.  
  19.     rst.Open "SELECT * FROM BLAG WHERE UPPER(id) = UPPER('12aBxY')", cnn, adOpenForwardOnly
  20.  
  21. End Sub
Feb 5 '08 #2

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

Similar topics

6
1592
by: WindAndWaves | last post by:
Hi Everyone, Here is another question: I run a database in Access RT in a Virtual PC environment. Every now and then I get an error: "Object Not set", which then freezes everything. Not...
3
2604
by: JMCN | last post by:
hello i am in the midst of converting all of the "inherited" databases from access 97 to access 2000. one of the issues i have is the basic one: dao.recordset. i have read that i need to simply...
4
2531
by: JMCN | last post by:
object invalid or no longer set - confusion of the recordset in access 2003. i am currently converting from access 97 to access 2003. majority of the codes converted over perfectly fine, though...
42
5581
by: PC Datasheet | last post by:
I have zero experience with using a SQL database for a backend and Access for a frontend. I have some questions: 1. Does an SQL database have tables? 2. How does Access connect to the data in...
5
1804
by: DeanL | last post by:
I know you can convert a database from Access 2003 to 97 easily but is there anything that I should avoid doing in Access 2003 that might make my database incompatible with Access 97? Many...
1
6461
by: Chris | last post by:
Is there any advantage for using "Microsoft Office 12.0 Access Database Engine Object Library" instead of DAO360.DLL for Access 2007 ?
5
3249
by: bobdydd | last post by:
Hi Everybody I am currently updating a 2000.mdb to a 2007.accdb and I am trying to use the 3.6 DAO Object Library in the tools>references in the vb editor. This produces an error "Name conflict...
0
18753
NeoPa
by: NeoPa | last post by:
Many of us have noticed that there are some very useful functions available to you when using Excel, but these same functions are not available, as standard, in Access. A particular issue I had...
5
3535
by: Peter | last post by:
Hi, i've got an older Access program, which is written in the version 2000 and i'd like to use it with my new office 2007, so access 2007. In the program, there is an replication written with...
0
7273
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
7322
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
6982
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
7451
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
5572
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
4667
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1501
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.