Results 1 to 4 of 4
  1. #1
    GeorgeJ is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    67

    Running a changed select Query from code in an active form


    I am exploring this issue in another forum (Programming) and thought I would also post here in the Query form. The situation is this. I am trying to avoid using the filter properties of a form. I have a form F_Lists whose record source is the query ListQuery. Based on what the user types in a textbox which is on F_Lists, VBA code changes the SQL string of the query ListQuery. Then code runs a Requery and Refresh command. But the records shown in F_Lists do not reflect the fact that ListQuery has been changed. However, if I leave the form and then reload it I do get the results of the changed query. My question is, are there any VBA commands which I can put into the code file of F_Lists which will cause the program to run the changed query and show the results in the records shown in the form, without closing and reopening the form? (When I try the Execute command I get the message that this command doesn't work on a select query).

    Thank you in advance

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Why aversion to setting Filter property?

    If you have code that modifies QueryDef and Requery of form (I would not do this and never tried) doesn't work, then possible option is to set the form RecordSource property with the SQL statement instead of reference to query object.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  4. #4
    GeorgeJ is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    67
    Thanks for your response. I'm continuing this thread on another part of the forum.

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

Similar Threads

  1. Replies: 4
    Last Post: 05-06-2013, 12:56 PM
  2. Running SELECT query in MSACCESS
    By dolovenature in forum Programming
    Replies: 4
    Last Post: 09-12-2012, 06:16 AM
  3. Replies: 5
    Last Post: 02-06-2012, 03:58 PM
  4. running select query in form delete event
    By suki360 in forum Programming
    Replies: 0
    Last Post: 03-11-2011, 10:11 AM
  5. Select query for running totals
    By asawadude in forum Queries
    Replies: 2
    Last Post: 10-07-2010, 03:41 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