Solved

SendKeys disables numlock. Is there a fix?

Posted on 2006-07-03
23
632 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
 
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now