• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 819
  • Last Modified:

SendKeys disables numlock. Is there a fix?

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
PstWood
Asked:
PstWood
  • 10
  • 8
  • 2
  • +2
1 Solution
 
Leigh PurvisDatabase DeveloperCommented:
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
 
rockiroadsCommented:
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
 
rockiroadsCommented:
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
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
rockiroadsCommented:
try this if u want to set numlock


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

0
 
PstWoodAuthor Commented:
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
 
rockiroadsCommented:
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
 
jefftwilleyCommented:
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
 
Carl2002Commented:
I must be special - my numlock does not go off
0
 
rockiroadsCommented:
Neither does mine

the only way I got numlock to go on/off was the WshShell code
0
 
PstWoodAuthor Commented:
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
 
PstWoodAuthor Commented:
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
 
PstWoodAuthor Commented:
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
 
PstWoodAuthor Commented:
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
 
Leigh PurvisDatabase DeveloperCommented:
Not being a big sendkeys fan I'm curious - did the code from the Access Web not work?
0
 
PstWoodAuthor Commented:
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
 
PstWoodAuthor Commented:
Actually it was the URL that RockyRoads posted that had the answer.

Thanks again.
RWW
0
 
rockiroadsCommented:
So what was your final solution.
0
 
PstWoodAuthor Commented:
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
 
rockiroadsCommented:
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
 
PstWoodAuthor Commented:
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
 
jefftwilleyCommented:
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
 
PstWoodAuthor Commented:
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
 
rockiroadsCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 10
  • 8
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now