Results 1 to 3 of 3
  1. #1
    thestappa is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2008
    Posts
    16

    How can I update a query using VBA?

    I'm trying to update the SQL of my query via vba.



    I'm trying to do that so I can have one query for a PIVOTCHART that I can just change the where clause on viewing. There doesn't seem to be a way to change the where clause when doing
    Code:
    docmd.openquery.
    I figured I could just have a base query, grab the sql and add the where clause. I just can't seem to figure out how to take the new sql and save it to a different query.

    Thanks

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Well, you can use a DAO QueryDef object to change the SQL, but from what you've described, I would think you could just have a WHERE clause that pointed to a form where the user inputs their criteria. Unless you're actually changing which fields have criteria applied to them (and maybe even then), that's what I'd do.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    thestappa is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2008
    Posts
    16
    Quote Originally Posted by pbaldy View Post
    Well, you can use a DAO QueryDef object to change the SQL, but from what you've described, I would think you could just have a WHERE clause that pointed to a form where the user inputs their criteria. Unless you're actually changing which fields have criteria applied to them (and maybe even then), that's what I'd do.

    I tried passing a where clause to a report (with chart) and was having a heck of a time getting it to work. Maybe I'll try that again.

    I could get the chart to work no problem but the where clause wouldn't work.

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

Similar Threads

  1. Update query help
    By techexpressinc in forum Queries
    Replies: 4
    Last Post: 03-31-2010, 07:13 AM
  2. Update Query- selective update?
    By stephenaa5 in forum Queries
    Replies: 1
    Last Post: 10-29-2009, 11:15 AM
  3. Update Query
    By GrnISSO in forum Queries
    Replies: 0
    Last Post: 06-15-2007, 05:41 PM
  4. Need help with an Update query ...
    By valkyry in forum Queries
    Replies: 0
    Last Post: 04-23-2007, 08:45 PM
  5. Need help with Update Query
    By starswinger007 in forum Queries
    Replies: 1
    Last Post: 02-22-2006, 08:44 PM

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