Results 1 to 4 of 4
  1. #1
    laavista is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2010
    Posts
    42

    Create a query in VBA, Access 2007

    I need to create a query in VBA. I'm using Access 2007.



    I have a combo box and based on the user's selection(s), a 'where clause' is created. I need to either create a query that includes my where clause, or use an existing query and use the where clause.

    I had created a query in VBA in Access 2003 using DAO defs, e.g.,
    set qdef = MyDB.CreateQueryDef("q_regions", strSQL)
    This does not work in 2007.

    Any suggestions would be greatly appreciated.

  2. #2
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    generic advice to all struggling in making a vb based query.....set it up using plain ole query design - - and then use the SQLview feature to see the syntax...which you can copy over to your vb statement with only minor syntax changes....

  3. #3
    laavista is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2010
    Posts
    42

    Thanks

    Thanks for the advice.

    I just solved this. I was attempting to use DAO, but Access 2007 does not use it.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Not clear what you mean with that last statement. You can certainly use DAO in 2007.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 12-30-2009, 11:03 AM
  2. access 2007; sql query in a field?
    By cmdturk in forum Access
    Replies: 4
    Last Post: 12-16-2009, 10:25 AM
  3. Replies: 0
    Last Post: 11-17-2009, 02:35 PM
  4. Using a query to create
    By DamnYankees in forum Queries
    Replies: 2
    Last Post: 10-08-2009, 07:38 PM
  5. Replies: 32
    Last Post: 09-16-2009, 10:06 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums