Prevent DownKey

B

bhammer

I have an ActiveX SplitBar control on my form that works great. It has a
quirk that happens if the user presses the DownArrow key after resizing the
splitbar (i.e., it has the focus). So I want to prevent it, or redirect the
focus.

I tried setting the focus after the OnChange and DownKey events but the
focus did not move.

Ideally I would like to move the focus a subform (the splitbar is on the
main). Even better, I'd like to move the focus to the record on the subform
that was current before the user moved the splitbar! (the current record
moves to first, for some reason after the splitbar is moved, also annoying).

Concept:
Sub Splitbar_Resize()
With Me.Subform
.Setfocus
Form.GoTo.RecordWithPreviousFocus
End Sub

-Brad
 
C

ChrisJ

Try this...

In the form event properties set "Key Preview" on

In the form "KeyDown" eventdo a test like

If me.ActiveControl = me.[Name OfSplitterControl] then
'check for downarrow
'set the keycode = 0 if you do not want the keystroke to do anything else
'set the focus where you want
 
B

bhammer

ChrisJ said:
Try this...

In the form event properties set "Key Preview" on

In the form "KeyDown" eventdo a test like

If me.ActiveControl = me.[Name OfSplitterControl] then
'check for downarrow
'set the keycode = 0 if you do not want the keystroke to do anything else
'set the focus where you want



bhammer said:
I have an ActiveX SplitBar control on my form that works great. It has a
quirk that happens if the user presses the DownArrow key after resizing the
splitbar (i.e., it has the focus). So I want to prevent it, or redirect the
focus.

I tried setting the focus after the OnChange and DownKey events but the
focus did not move.

Ideally I would like to move the focus a subform (the splitbar is on the
main). Even better, I'd like to move the focus to the record on the subform
that was current before the user moved the splitbar! (the current record
moves to first, for some reason after the splitbar is moved, also annoying).

Concept:
Sub Splitbar_Resize()
With Me.Subform
.Setfocus
Form.GoTo.RecordWithPreviousFocus
End Sub

-Brad

Chris,

Thanks for the idea. This is what eventually worked for me:

CODE START
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
On Error Resume Next

Me.frmDefectListRight.SetFocus

End Sub

CODE END

Since I have no textboxes or other data input on the Main form, I can use
the KeyDown event to simply move the focus to the subform.

-Brad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top