Results 1 to 3 of 3

Thread: Queries in Code

  1. #1
    Join Date
    Mar 2002
    Posts
    192

    Unanswered: Queries in Code

    I want to create a query in code. I'm using a MS Access 2000 database. I do not want to use older methods of query creation I.E. only use what's built in if possible no DAO.

    I've identified a technique. The only drawback is that it creates Invisibile queries! Does anyone know of a method that works just like the old DAO / CreateQueryDefs method?

    The current method I'm trying does not result in queries that appear in the Database Window (Even through they actually exist)

    METHOD 1

    dim cn as adodb.connection

    set cn = currentproject.connection
    cn.execute "Create View qryTest as Select * from tblTest'"
    cn.close
    set cn = nothing

  2. #2
    Join Date
    Oct 2003
    Location
    US
    Posts
    343
    I don't think so. The method you are using creates queries on the fly. To actually create a phsical query you'll have to use querydefs collection to add a query to your db. This is as far as I know. maybe someone has a better solution.

  3. #3
    Join Date
    Oct 2003
    Location
    Roanoke, Va
    Posts
    445

    Question Re: Queries in Code

    Originally posted by access_dude
    I want to create a query in code. I'm using a MS Access 2000 database. I do not want to use older methods of query creation I.E. only use what's built in if possible no DAO.

    I've identified a technique. The only drawback is that it creates Invisibile queries! Does anyone know of a method that works just like the old DAO / CreateQueryDefs method?

    The current method I'm trying does not result in queries that appear in the Database Window (Even through they actually exist)

    METHOD 1

    dim cn as adodb.connection

    set cn = currentproject.connection
    cn.execute "Create View qryTest as Select * from tblTest'"
    cn.close
    set cn = nothing
    Are you opposed to using the DoCmd object with the RunSQL method?

    This is stuff intrinsic to the Access library.

    Gregg

Posting Permissions

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