[AccessD] Clear Keyboard Buffer

Jim Dettman jimdettman at verizon.net
Tue May 11 09:31:55 CDT 2021


Rocky,

<< What I want is for the program NOT to process
any pending events from the keyboard.  >>

 DoEvents won't do that.  It will process anything already in the queue.

 The way DoEvents works is that it pauses execution until all window
messages have been processed along with any keystrokes.  It also gives up
the current processing cycle to other apps.   It was mainly meant for
working with OLE apps outside of Access.

 <<
So now I'm wondering if there's a way I could disable the keyboard at the
top of the Current even and re-enable it before exiting the event code?
>>

To flush the keyboard without processing anything, you'd need to use the
code that Jack showed this morning (a winapi call).   The other way you
could go at it is to turn on Form KeyPreview, then based on a flag, either
eat up the keystroke, or let it process based.

Jim. 
  

-----Original Message-----
From: AccessD On Behalf Of Rocky Smolin
Sent: Tuesday, May 11, 2021 10:09 AM
To: Access Developers discussion and problem solving
<accessd at databaseadvisors.com>
Subject: Re: [AccessD] Clear Keyboard Buffer

Jim:

I tried that but no cigar.  What I want is for the program NOT to process
any pending events from the keyboard.  When you say process, how does that
affect the program when the DoEvents is at the top of the Current event
module?

I may have found a workaround, though. Using the Access Navigation buttons
I have not been able to create this error regardless of how fact I hit the
next record navigation button.  I suspect that Access is not accepting any
more keystrokes until the next records fetched and loaded.

So now I'm wondering if there's a way I could disable the keyboard at the
top of the Current even and re-enable it before exiting the event code?

r
On Tue, May 11, 2021 at 5:07 AM Jim Dettman via AccessD <
accessd at databaseadvisors.com> wrote:

>
>  Should also be worth noting that DoEvents  will process all keyboard
> events.
>
> Jim.
>
> -----Original Message-----
> From: AccessD On Behalf Of jack drawbridge
> Sent: Tuesday, May 11, 2021 8:01 AM
> To: Access Developers discussion and problem solving
> <accessd at databaseadvisors.com>
> Subject: Re: [AccessD] Clear Keyboard Buffer
>
> Rocky,
> Here is an old thread that mentions clearing the keyboard buffer
> <
> https://www.mrexcel.com/board/threads/flushing-the-keyboard-buffer.254206/
> >
> .
> Know nothing other than I found it with Google. Hope it's helpful.
>
> On Mon, May 10, 2021 at 6:33 PM Rocky Smolin <rockysmolin2 at gmail.com>
> wrote:
>
> > Dear List(s):
> >
> > I have a form with a subform and I have two command buttons that do Next
> > Record and Previous Record.  No problem.
> >
> > Until someone tries to hit the Next Record or Previous Record real fast
> and
> > then I get an error about the subform not existing.
> >
> > It's a timing thing I'm sure. Might be the keyboard buffer overflowing.
> And
> > I'm thinking that one way to get around the problem (assuming there
isn't
> a
> > right way to do this) is to clear the keyboard buffer on entering the
> > Current event where this is happening.
> >
> > But I can't find anything through Google about clearing the keyboard
> buffer
> > in VBA (2010).
> >
> > Is there a simple way to do this?
> >
> > MMTIA
> >
> > Rocky
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > https://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
-- 
AccessD mailing list
AccessD at databaseadvisors.com
https://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list