Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2012

    Unanswered: Requery on key strokes


    Say I've got a form with a text box, txtSearchFor, and a subform, Subform1. The recourd source of the subform is a select query that uses a like condition "*" & txtSearchFor & "*" in one of the fields.

    If I use a simple macro to requery the subform when I update the text box then I can filter the subform and it works just fine. (I should maybe use code but I couldn't get the syntax right so I used a macro instead)

    However I'd like to requery each time the user presses a key whilst typing into the text box so the records are filtered in real time.

    I know what some of you will say, that this is very inefficient, but I want to test the performance of it nonetheless because it would be the most useful funcionality.

    I tried putting the same macro in the on change event but I get odd behaviour. If I type a letter into the box, nothing happens, if I type another letter, nothing happens. If I click on another control and then back on the box, nothing happens, but THEN if I type another letter the records are filtered by the previous letters I typed before clicking away, but not by the new one that triggered the event.

    Am I using the wrong event? Is there a way to do what I'm trying to do? i.e. refresh/requery the subform each time any key is pressed but still keeping the cursor in the textbox?

    This is very nearly the last form I have to make so I'm almost done. Any help in getting me past the finish line would be awesome.


  2. #2
    Join Date
    Jul 2012

    Never mind...

    I found the solution here, from this very website in fact. Works perfectly. Score!

  3. #3
    Join Date
    Jun 2005
    Richmond, Virginia USA
    Provided Answers: 19
    You could try using the KeyDown event for the particular Textbox. Allen Browne has a tried and tested hack for doing this sort of thing. You may be able to get some pointers out of it:

    Microsoft Access tips: Find records as you type

    Linq ;0)>
    Hope this helps!

    The problem with making anything that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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