Solved

SendKeys disables numlock. Is there a fix?

Posted on 2006-07-03
23
685 Views
Last Modified: 2011-10-03
I have the following in both an onClick and gotFocus event procedure on one of my forms.

    SendKeys "+{F2}"
    SendKeys "{LEFT}"
    IndicatorsUsed.SelLength = 0

The interesting thing is that when the field is accessed, either by clicking or by tabbing, the keyboard Num Lock goes off, ie. you can't use the number pad without hitting the Num Lock key first.

Is there any fix or workaround for this?

Thanks.
RW Wood

PS - I tried using     SendKeys "{NUMLOCK}" at the end of the procedure, but it does nothing.
0
Comment
Question by:PstWood
  • 10
  • 8
  • 2
  • +2
23 Comments
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 17030655
Suprised you've only just found out of you're a sendkeys fan.
It's a well known issue.
http://www.mvps.org/access/bugs/bugs0004.htm
http://www.mvps.org/access/api/api0046.htm
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17030669
so it does, but with mine, numlock came back on again when the zoom window activated

try this


SendKeys "+{F2}+{F2}"

also why dont u set SelLength before the sendkeys or remove it altogether

0
 
LVL 65

Accepted Solution

by:
rockiroads earned 125 total points
ID: 17030689
Ok, MS Access says its down to multiple statements
http://support.microsoft.com/?kbid=179987

so try the F2F2 together, see if that makes a difference
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 65

Expert Comment

by:rockiroads
ID: 17030754
try this if u want to set numlock


Set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys "{numlock}"

0
 

Author Comment

by:PstWood
ID: 17031039
The double F2 solution didn't work, nor did removing SelLength, and using your last suggestion resulted in
Compile error:
Variable not defined.

Good Ole M$.

So.... any other suggestions for being able to "expand" the textbox on a form to be able to see all the contents?

Thanks.
rww
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17031149
did u try it with DoEvents?
Suggest u have one common function so there is no need to duplicate
assuming IndicatorsUsed is a textbox

Private Sub IndicatorsUsed_Click()
    OpenZoom IndicatorsUsed
End Sub

Private Sub IndicatorsUsed_GotFocus()
    OpenZoom IndicatorsUsed
End Sub

Private Sub OpenZoom(ctl As Control)
    ctl.SetFocus
    SendKeys "+{F2}"

'Im assuming u specify a left because current text is hilighted?
    DoEvents
    SendKeys "{LEFT}"

End Sub




with the wshshell, define the variable and try it

Dim WshShell as Object

Set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys "{numlock}"

0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 17031242
Hi PstWood,
Wondering if you considered making your own small form you could call that is simply an expanded text box that you could call with an openform event. Lots more flexibility that way...and you can add additional controls to it if you wanted to. That form could be called as a function passing in the arguement for content.

Something like this???

Function ZoomField(strData As String)
DoCmd.OpenForm "MYNEWFORM", acNormal, , "MYTEXTFIELD.value = " & strData
End Function

J
0
 
LVL 4

Expert Comment

by:Carl2002
ID: 17031389
I must be special - my numlock does not go off
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17031530
Neither does mine

the only way I got numlock to go on/off was the WshShell code
0
 

Author Comment

by:PstWood
ID: 17033851
I'll try these out. I'm leaning toward Jeff's suggestion of a separate form. Interesting that some people don't have the problem, though. Which version of windoze and of Access are you using?
0
 

Author Comment

by:PstWood
ID: 17034879
Jeff,

Assuming I design a simple form as you suggested, how could I pass the record source to the form from the onOpen event? I have a couple of forms where frmZoom would be implemented, and it would make sense to reuse the same form as the pop-up for different record sources.

Thanks.
rww
0
 

Author Comment

by:PstWood
ID: 17034923
I think I figured the above out. The function you gave me was for the onClick event of the original form and it wouldn't matter which form that was. I'll try it.
0
 

Author Comment

by:PstWood
ID: 17034967
Sorry. I didn't know what I thought I knew. OK. I give up. How do I use the function that you gave me above?

Thanks.
rww
0
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 17035493
Not being a big sendkeys fan I'm curious - did the code from the Access Web not work?
0
 

Author Comment

by:PstWood
ID: 17036069
To LPurvis:

Somehow I missed your comment, went back and found it, checked the MS site, and remedied the problem by simply combining the SendKey statements into one line. Easier than doing a new form, etc. You get the points.

Thanks to all.
RWW
0
 

Author Comment

by:PstWood
ID: 17036076
Actually it was the URL that RockyRoads posted that had the answer.

Thanks again.
RWW
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17038160
So what was your final solution.
0
 

Author Comment

by:PstWood
ID: 17038443
SendKeys "+{F2}{LEFT}"

Apparently by putting the keys sent all in one statement, there is no problem. As you said, I didn't need the SelLength either.

Thanks.
rww
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17038660
Thanks.
I guess I was close when I said put it in one line or use DoEvents like the link suggested.
But for feedback purposes, if I wrote down exactly what u wanted i.e. your solution, would I of got a A?
0
 

Author Comment

by:PstWood
ID: 17039470
Actually, I'm always doubtful about how to grade. Usually, if I get a solution or if people have just taken time to help me, I figure they deserve an A. I rechecked the tips for grading, and one of the things mentioned for a B was having to go to another site to find the answer. It was only on that basis that I gave the B. I think that all of the rest of the questions in which you have provided me an answer have gotten an A. In reality, I would have preferred to give you an A- or B+.

Thanks again.
rww
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 17039528
Hey PW,
I apologise as well...I've been in an out for the 4th holiday and didn't follow up on this thread. I didn't intend to ignore you nor your questions...If you'd like me to follow up...then please let me know.

<Hey Rocki...are you doing better? Worried about you!>
J
0
 

Author Comment

by:PstWood
ID: 17039698
Thanks, Jeff. I think I'm gonna stick with the zoombox as the easy solution now that I've figured out how to not have the numlock disabled.
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17040353
Hi Jeff, Im okay man, thanks. Problems dealt with, lets see what happens though. Hope u had a good 4th July. Dominated here by 2 news items - Space Shuttle Launch and North Korea Missile Launch.

PstWood, no problems. I like to get feedback that is all, I understand your reasons
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question