D
Dale Fye
I'm playing around with a contact management database.
I've been playing around with a process to duplicate the functionality seen
in the Outlook contacts list phone number section. I've got a popup menu
that displays when the user clicks on a label that indicates the type of
phone number. When the user selects from the popup, it changes the caption
of the label and the query of the form so that it returns only the records
for that type of phone. This is all in a subform, and works smoothly.
The problem is that since each phone number is displayed in its own subform,
when the user tabs out of the phone #, the cursor goes back to the Area Code
field for that phone type. I've got the KeyPreview set to Yes, and in the
KeyDown event of txt_Phone_Number I'm checking for KeyCode = vbKeyTab. If
it is, then I call a public function on the parent form (see below), but
nothing I seem to do actually sets the focus to the Area Code control on the
next phone number.
Private Sub txt_Phone_Number_KeyDown(KeyCode As Integer, Shift As Integer)
if KeyCode <> vbKeyTab then exit sub
'I have some error checking code in here, deleted for clarity
'.....
'Valid phone number, set focus the the Area Code field in the next
sub_Phone subform
Call Me.Parent.NextPhone
End Sub
Public Sub NextPhone()
Dim intPhone As Integer
Dim strControl As String
intPhone = Right(Me.ActiveControl.Name, 1)
'Move the focus to the next phone subform
strControl = "sub_Phone" & (intPhone + 1)
On Error Resume Next
Me.Controls(strControl).Form.txt_Area_Code.SetFocus
Debug.Print Err.Number, Err.Description
if Err.Num <> 0 then
'set focus to the control with the next lowest tab index.
endif
End Sub
I've been playing around with a process to duplicate the functionality seen
in the Outlook contacts list phone number section. I've got a popup menu
that displays when the user clicks on a label that indicates the type of
phone number. When the user selects from the popup, it changes the caption
of the label and the query of the form so that it returns only the records
for that type of phone. This is all in a subform, and works smoothly.
The problem is that since each phone number is displayed in its own subform,
when the user tabs out of the phone #, the cursor goes back to the Area Code
field for that phone type. I've got the KeyPreview set to Yes, and in the
KeyDown event of txt_Phone_Number I'm checking for KeyCode = vbKeyTab. If
it is, then I call a public function on the parent form (see below), but
nothing I seem to do actually sets the focus to the Area Code control on the
next phone number.
Private Sub txt_Phone_Number_KeyDown(KeyCode As Integer, Shift As Integer)
if KeyCode <> vbKeyTab then exit sub
'I have some error checking code in here, deleted for clarity
'.....
'Valid phone number, set focus the the Area Code field in the next
sub_Phone subform
Call Me.Parent.NextPhone
End Sub
Public Sub NextPhone()
Dim intPhone As Integer
Dim strControl As String
intPhone = Right(Me.ActiveControl.Name, 1)
'Move the focus to the next phone subform
strControl = "sub_Phone" & (intPhone + 1)
On Error Resume Next
Me.Controls(strControl).Form.txt_Area_Code.SetFocus
Debug.Print Err.Number, Err.Description
if Err.Num <> 0 then
'set focus to the control with the next lowest tab index.
endif
End Sub