473,395 Members | 1,756 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

To Zoom with SendKeys, Shift F2, use DoEvents

446 Expert 256MB
Hi
I have often wanted to allow users to double-click on a control to open the Zoom window, instead of having to revert to the Shift +F2 keyboard method.

The command SendKeys "+{F2}" works for the On_Click event but not for Double_Click. You can open a message box but not the Zoom window!

However, I have found that by putting a DoEvents after the SendKeys, it works reliably.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Narrative_DblClick(Cancel As Integer)
  2. 'MsgBox "Double Click detected"
  3. SendKeys "+{F2}"
  4. DoEvents
  5. End Sub
This has bugged me for years so I was happy to find a fix.

Incidentally, I'm finding I need to put DoEvents in previously reliable code, after functions or calling procedures, to try and keep things synchronized. Whether this is because computers are faster or later versions of Access try multi-tasking, I don't know.

S7
Mar 19 '08 #1
5 12181
missinglinq
3,532 Expert 2GB
You should never use SendKeys unless nothing else is available, which is not the case here!
Expand|Select|Wrap|Line Numbers
  1. Private Sub YourTextBox_DblClick()
  2.   DoCmd.RunCommand acCmdZoomBox
  3. End Sub
I have no idea on your DoEvents problem; never experienced it or read about it anywhere else. Perehaps your explanation is correct. What type of procedures are involved?

Linq ;0)>
Mar 19 '08 #2
FishVal
2,653 Expert 2GB
DoEvents passes control to the operating system. Control is returned after the operating system has finished processing the events in its queue and all keys in the SendKeys queue have been sent.
Quite straightforward I guess. The question is why it worked previously.

Regards,
Fish.
Mar 19 '08 #3
missinglinq
3,532 Expert 2GB
Of course, using Why and SendKeys in the same sentence has always been a pretty futile exercise! There's never really been any rhyme or reason as to what they do or don't do!

Linq ;0)>
Mar 19 '08 #4
sierra7
446 Expert 256MB
You should never use SendKeys unless nothing else is available, which is not the case here!
Expand|Select|Wrap|Line Numbers
  1. Private Sub YourTextBox_DblClick()
  2. DoCmd.RunCommand acCmdZoomBox
  3. End Sub
I have no idea on your DoEvents problem; never experienced it or read about it anywhere else. Perehaps your explanation is correct. What type of procedures are involved?

Linq ;0)>
Thanks for the comments guys! I thought that might get a response.

Thanks for the tip about acCmdZoomBox Linq. I failed to find that one! I agree totally about not using SendKeys and if this tests successfully, will swap at the next opportunity.

I haven't seen the Help topic refered to by Fish but originally used DoEvents to get other command buttons to respond while continuously looping to read data off COM1.

Since migrating a '97 project to 2003, one subform in particular showed #Error after a 'stock picking operation' when previously all was OK under '97. The system does things like;- find next next Invoice number; reduce quantity remaining on Batch, add quantity & BatchID to picked material; calculate and display profit. Nothing really difficult but requires steps to be performed in an orderly fashion. The text box for 'profit' showed #Error (which was disconcerting to the user!) although correct figures displayed on re-opening the form. Tried Refresh, Recalc, even Requery but found that DoEvents between the procedures worked. End of!

S7
Mar 19 '08 #5
missinglinq
3,532 Expert 2GB
DoEvents is always a good thing to try when you have muliple things running where some things may take a bit of time to complete. I've had to use it where a single button was used to print out multiple reports.

Still don't have a clue why you have to use it now when you didn't in ACC97. Never worked in 97. In every version since 2000 operations are asynchronous, but maybe that wasn't true in 97.

Linq ;0)>
Mar 19 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Daniel Kaffee | last post by:
Please, please, please can somebody post here how to use the Sendmessage API call to send the keystrokes Alt B, "Y", Tab (*7), "Danny" to an application that I have the windows handles and PID's...
7
by: Paul Cooper | last post by:
Dear All, I am working on a piece of Javascript code that needs to detect a mouse-click, shift-click and control-click. The code is not my own - it is a part of a much larger suite of routines....
10
by: Deano | last post by:
I think that just about sums it up. Is there a fix/workaround for this?It's quite annoying behaviour and not user-friendly.thanksMartin
1
by: John Richardson | last post by:
I'm trying to override the SHIFT-SPACE "negative feature" in the Winforms datagrid, to only be a space. The following link describes this:...
3
by: Phil Galey | last post by:
I have a VB.NET application that uses SendKeys to close the open document in QuarkXPress 5.0 I'm using the following commands: AppActivate(QXP_Process_ID) SendKeys.SendWait("^{F4}") in an...
5
by: Daniel N. | last post by:
I am trying have an application hold down the Shift key (+) and the Alt key (%) simultaneously for a given period of time, or until a condition is met. I tried this but it doesn't work:...
2
by: MLH | last post by:
I have the following code with a SendKeys statement in it. 100 If Me.Dirty Then MsgBox "Form is Dirty!" 120 Dim MyQ As String, MyTitle As String, Response As Boolean 140 MyQ =...
4
by: wasishincar | last post by:
I'm trying to read a bitmap and zoom in/out it on screen. I wrote some code but it did not perform as I expect. The bitmap shift 1 pixel to the upper-left coner when zooming in/out button was...
6
hyperpau
by: hyperpau | last post by:
There is a certain feature in access that allows you zoom in a field to have a clearer view. For example, if the form is in datasheet view and the memo field only shows you the first few words of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.