+ Reply to Thread
Results 1 to 7 of 7

VBA - create query with ADO in Access application

  1. #1
    Registered User
    Join Date
    08-26-2012
    Location
    amsterdam
    MS-Off Ver
    Excel 2003
    Posts
    34

    VBA - create query with ADO in Access application

    Hi everybody,

    Hope somebody can help me out. I want to create a query with ADO in Excel in an Access application. I found some code on the website of Jon van der Heyden: http://jonvonderheyden.net/excel/add...ures-with-vba/

    However when I use his code I get a compile error: user defined type not defined. I set my reference to ADO but it still does not work. Does anybode know why this error is popping up?

    Attached an excel file with the code.

    Thanks in advance,

    Michiel
    Attached Files Attached Files

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: VBA - create query with ADO in Access application

    I have a sheet I connect to an Access database with and I don't see any code that looks familiar. Where is the code? Which module?
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  3. #3
    Registered User
    Join Date
    08-26-2012
    Location
    amsterdam
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: VBA - create query with ADO in Access application

    Sorry I mistook for another file. See attached for the correct file.

    Michiel
    Attached Files Attached Files

  4. #4
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: VBA - create query with ADO in Access application

    What line is giving you the error?

  5. #5
    Registered User
    Join Date
    08-26-2012
    Location
    amsterdam
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: VBA - create query with ADO in Access application

    It refers to this line:

    Public Sub CreateQuery(ByVal strDBPath As String, _
    ByVal strSql As String, ByVal strQueryName As String, _
    ByVal vpType As ViewOrProc)

  6. #6
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: VBA - create query with ADO in Access application

    I'm certainly not an expert, but I'm hoping I find something obvious. My first question would be where are you calling this procedure from? I ask because when I search the code I can't find where you have defined strDBPath, so I wonder where you are giving that a value to pass to this procedure.

    Also I don't know if the references would be an issue because it looks like this code is late binding code.

  7. #7
    Registered User
    Join Date
    08-26-2012
    Location
    amsterdam
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: VBA - create query with ADO in Access application

    All,

    Thanks. Somehow part of the code was fallen away. Attached the proper file and code.

    sorry for the inconvenience.

    Michiel
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Will VBA Access.Application command run in Access Runtime (2010) only
    By hydz1213 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-17-2013, 05:51 AM
  2. Access VBA or SQL to create a query that has matching data from 2 tables
    By ewong in forum Access Programming / VBA / Macros
    Replies: 15
    Last Post: 09-13-2012, 04:42 PM
  3. Replies: 9
    Last Post: 07-31-2012, 05:54 PM
  4. [SOLVED] Access.Application.Quit - opens Access again then won't close - He
    By Hluhluwe in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-30-2006, 07:20 AM
  5. Create Excel PivotTable that uses Access query as external data so
    By alexhatzisavas in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-30-2005, 04:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1