hotrod1952 via AccessMonster.com said:
I have form with several controls. When a data is input into the control I
am
setting the next control visible and setting focus to it. what is the best
way in code to determine the tabindex of the latest visible control.
example
control1 after update makes control 2 visible and sets focus to it. Form
entry person moves mouse to control 1. On a command button (no tabstop on
this one) I need to find that conrol 2's tabindex is the current highest
position not control 3 .... which is not yet visible.
I'm not entirely sure I understand you , but maybe you can adapt this
function to your purpose, or at least use it as a demonstration of the
properties you'll have to work with.
'----- start of code -----
Function NextInTabOrder(StartCtl As Access.Control) As String
' Returns the name of the next active control in the tab order,
' if possible. Returns a null string if there isn't one.
Dim astrControlNames() As String
Dim obj As Object
Dim ctl As Access.Control
Dim intI As Integer
On Error Resume Next
'to ignore errors we expect to raise
Set obj = StartCtl.Parent
ReDim astrControlNames(obj.Controls.Count)
' Build a list of available controls indexed by TabIndex.
' We aren't interested in controls that are invisible,
' disabled, not a tab stop, or not in the same section
' as StartCtl.
For Each ctl In obj.Controls
With ctl
If .Section = StartCtl.Section Then
If .Visible = True _
And .Enabled = True _
And .TabStop = True Then
astrControlNames(.TabIndex) = .Name
End If
End If
End With
Next ctl
Set obj = Nothing
' Loop forward through the list
For intI = StartCtl.TabIndex + 1 To UBound(astrControlNames)
If Len(astrControlNames(intI)) > 0 Then
NextInTabOrder = astrControlNames(intI)
Exit Function
End If
Next intI
' If we didn't find one, start at the beginning of the list.
For intI = 0 To StartCtl.TabIndex - 1
If Len(astrControlNames(intI)) > 0 Then
NextInTabOrder = astrControlNames(intI)
Exit Function
End If
Next intI
' If we get here, there's no available control.
Exit Function
End Function
'----- end of code -----