Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 14th, 2006, 11:26 PM
bl bl is offline
Registered User
 
Join Date: Nov 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Queries from VBA

I have the following code from a sub in an .mdb file, which works perfectly. However, I am trying to do pretty much exactly the same thing for a stored procedure in an .adp file. So far, I have been completely unsuccesful in doing this, any help would be greatly appreciated.


Dim db As DAO.Database
    Dim qdf As DAO.QueryDef
    Dim strSQL As String
    Set db = CurrentDb
    Set qdf = db.QueryDefs("Query3")

DoCmd.Close acQuery, "query3"

strSql = 'some functions that generate the sql code for the query in question

qdf.SQL = strSQL
DoCmd.OpenQuery "Query3", , acReadOnly

 
Old November 15th, 2006, 08:23 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You can't use DAO with an adp. You need to use ADO to talk to a SQL server.



mmcdonal
 
Old November 15th, 2006, 06:27 PM
bl bl is offline
Registered User
 
Join Date: Nov 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

okay, I have to use ADO, any suggestions.






Similar Threads
Thread Thread Starter Forum Replies Last Post
improve vba access queries using indexes jani Access 1 July 22nd, 2008 07:06 AM
Code works in Excel VBA but not Access VBA fossx Access VBA 2 May 21st, 2007 08:00 AM
Modifying The Queries Dialog Box VBA code Ben Horne Access VBA 1 September 26th, 2006 04:22 PM
Combining Queries or results from 2 queries Ford SQL Server 2000 24 November 7th, 2005 08:54 PM
writing SQL queries in MS access,VBA NovieProgrammer Access VBA 2 April 2nd, 2005 07:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.