473,804 Members | 2,271 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 2587
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
1605
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 even CTRL + ALT + DELETE can really help. Any idea what I can do to solve this problem???
3
2623
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 turn off the ADO reference and change the reference ms dao 3.6 object library to ms dao 3.51 object library or "disambiguate the code". i tried both and i still receive the error message "run time error 3420 - object invalid or no longer set."
4
2546
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 my recordset did not. i read from pasts posts that some references will not convert. so i tried to change the dao 3.51 reference to dao 3.6 in access 97. then i imported all of the objects into an access 2003. it did not work. so my second...
42
5658
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 an SQL database? Linking, importing, or ??? 3. Earlier today there was a thread regarding DAO and ADO. In the thread it was said that ADO is very useful when the backend is a SQL database. Could someone explain that?
5
1817
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 thanks, Dean...
1
6480
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
3259
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 with an Existing Library" and yet I need this to run the following code. I have a combo property set to "Limit to List" and on the "not in list property" the following code needs to run
0
18808
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 recently (and I know others have come across this recently too) is rounding up and down. I know the Excel ROUNDUP() function rounds away from zero rather than upwards specifically, but is still useful in most circumstances. To allow an Access...
5
3556
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 the Jet Replica Library, and i read on a microsoft site, that replications in jet schould still work in access 2007, if you still use the old extension .mdb
0
9594
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10599
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10347
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10090
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5531
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4308
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 we have to send another system
2
3832
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.