[AccessD] moving focus off the tab page

Charlotte Foust cfoust at infostatsystems.com
Tue Jul 20 12:01:34 CDT 2004


I'm not sure this is what you're talking about, John, but I built this a
long time ago to handle a similar problem:

Public Function FirstFormControl(frm As Form, _
                                 Optional frmSection As Index = -1) As
String
  'created by Charlotte Foust 9/14/99
  'last modified 9/11/2000
  Dim ctl As Control
  Dim intTab As Integer
  Dim strCtlName As String
  Dim blnSkip As Boolean
  
  'Use the count of controls as the
  'maximum tab value
  intTab = frm.Count
  
  'Loop throught all controls on form
  For Each ctl In frm
    If frmSection <> -1 Then
      If ctl.Section <> frmSection Then
        blnSkip = True
      End If 'ctl.Section <> frmSection
    End If 'frmSection <> -1
    
    If Not blnSkip Then
      Select Case ctl.ControlType
        'If control can accept value
        'test its tab value against intTab.
        Case acTextBox, acOptionGroup, acComboBox, acListBox, _
            acCheckBox, acOptionButton, acCommandButton, _
            acToggleButton
          'If tab value less than intTab
          'set intTab = tab value and
          'set strCtlName = control name.
          If ctl.TabIndex < intTab Then
            If ctl.TabStop = True Then
              intTab = ctl.TabIndex
              strCtlName = ctl.Name
            End If 'ctl.TabStop = True
          End If 'ctl.TabIndex < intTab
      End Select 'Case ctl.ControlType
    End If 'not blnSkip
  Next 'ctl In frm
  
  'Return name of control with lowest tab value
  FirstFormControl = strCtlName
End Function 'FirstFormControl(frm As Form, _
                                 Optional frmSection As Index = -1)

Charlotte Foust


-----Original Message-----
From: Colby, John [mailto:JColby at dispec.com] 
Sent: Tuesday, July 20, 2004 8:09 AM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] moving focus off the tab page


Rocky,

The question is "what is the desired control to set the focus in", NOT
how to set the focus.

In any form, there is no single "tab index 0" control.  If you have a
header with controls in it, there will be one there.  If you have a
footer with controls, there will be one there.  There will be one in the
main part of the form.  Furthermore, if you have tab controls, EACH page
of the tab control has it's own tab order etc.  So.. if I am in the
header and tap the tab key I go one place, if I am in the footer and tap
the tab key I go another, if I am in the main part of the form I go a
third, if I am in page1 of the tab control I go another, if I am in page
2 of the form I go another.....  WHICH CONTROL WILL RECEIVE THE FOCUS IF
I TAP THE TAB KEY?

To complicate matters further, just because a control has tab index set
to 0 doesn't mean it can get the focus.  It may be invisible, it may be
disabled, or it may simply have it's property that allows it to be
"tabbed into" set to false.  My question is...

How do I determine WHICH control would get the focus if the tab key were
tapped?  The answer varies depending on whether there are tabs (if so
which tab is currently selected?), whether the current focus is in the
header / footer / body of the form, etc.  UGLY question, and Access is
no help at all determining the answer (AFAICT).  

This is one of those "the stupid bastards know the answer" (the tab key
works doesn't it?) but they don't expose the answer to me so I can set
the focus to that control using SomeControl.SetFocus syntax.

JWC.

-----Original Message-----
From: Rocky Smolin - Beach Access Software [mailto:bchacc at san.rr.com]
Sent: Tuesday, July 20, 2004 11:34 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] moving focus off the tab page


John:

Why can't you use the _Open event of the form to se the focus to the
desired control?

Rocky

-- 
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list