[AccessD] Key Preview Problem

Rocky Smolin - Beach Access Software bchacc at san.rr.com
Wed Mar 15 23:29:06 CST 2006


Marty:

I put Me.KeyPreview = True in the load event.  No luck.  I also put it 
at the end of the KeyDown event (where I shouldn't need to but just to 
cover that base).  No luck

So I put Msgbox KeyCode at the beginning of the KeyDown event.  The 
first time I press a function key it displays the code in the MsgBox.  
If I press any other key than the four function keys it displays they 
key code (Key Down event is still firing).  But after pressing one of 
the four function keys I'm trapping (F5-F8) the event stops firing.  
Processes the key stroke according to the code, but then stops firing.

So I comment out all of the .SetFocus and KeyCode = 0 lines and the 
event now keeps firing. I put back the KeyCode = 0 line and the event 
keeps firing.   I take out the KeyCode = 0 line and put back the 
.SetFocus line and the event stops firing.

So I've traced it down to the lines Me.pgXXX.SetFocus.  When that line 
executes it hoses the KeyPreview property and even setting it at the end 
of the module doesn't help.

Help!

Rocky


MartyConnelly wrote:
> Works for me in Access 2003 with the Form_Load method
>
> Rocky Smolin - Beach Access Software wrote:
>
>   
>> Marty:
>>
>> It's set to true in the Forms property sheet.  And it does work the 
>> first time I press one of the function keys.  But after that it doesn't. 
>>
>> Rocky
>>
>>
>> MartyConnelly wrote:
>>  
>>
>>     
>>> Stick this in or set in Forms properties, keypreview default is no.
>>>
>>> Private Sub Form_Load()
>>>  Me.KeyPreview = True
>>> End Sub
>>>
>>> Rocky Smolin - Beach Access Software wrote:
>>>
>>>  
>>>    
>>>
>>>       
>>>> Dear List:
>>>>
>>>> I have a tab form with four tabs.  I want to set the focus in each tab 
>>>> by pressing the functions keys F5, F6, F7, F8.  The KeyDown event is coded:
>>>>
>>>> Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
>>>>
>>>>   Select Case KeyCode
>>>>       Case 116
>>>>           Me.pgOrderNumber.SetFocus
>>>>           KeyCode = 0
>>>>       Case 117
>>>>           Me.pgReceiving.SetFocus
>>>>           KeyCode = 0
>>>>       Case 118
>>>>           Me.pgProcessing.SetFocus
>>>>           KeyCode = 0
>>>>       Case 119
>>>>           Me.pgShipping.SetFocus
>>>>           KeyCode = 0
>>>>   End Select
>>>>  
>>>> End Sub
>>>>
>>>> The first time I press one of the four function keys it works.  Then, it 
>>>> quits.  (Like if I press F7 the first time is sets the focus to 
>>>> pgProcessing, the second time it invokes the spell checker.)
>>>>
>>>> Does anyone know why this would happen?
>>>>
>>>> MTIA
>>>>
>>>> Rocky
>>>>
>>>>
>>>>
>>>>    
>>>>      
>>>>
>>>>         
>>>  
>>>    
>>>
>>>       
>>  
>>
>>     
>
>   

-- 
Rocky Smolin
Beach Access Software
858-259-4334
www.e-z-mrp.com




More information about the AccessD mailing list