asked on
ASKER
Private Sub SomeCommandButton_Click()
Dim ctl As Control
Dim I As Integer
On Error GoTo EH
' Outer loop defines the order based on TabIndex
For I = 1 To Me.Controls.Count
' Inner loop checks the control against the TabIndex determined by the outer loop
For Each ctl In Me.Controls
' This checks the control against the tab Index, and defines the control types you are checking
If ctl.TabIndex = I And (ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox) Then
' Print the control name. **** Your Validation checks would go here ****
Debug.Print ctl.Name & " " & ctl.TabIndex
End If
Next
Next
Exit Sub
EH:
' This handles 'property not found' errors for controls that don't have a TabIndex property
If Err.Number = 438 Then Resume Next
MsgBox "ERROR " & Err.Number & ": " & Err.Description
End Sub
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.
TRUSTED BY
the order that the control will be accessed is the order in which the control was placed in the form.
* first control that was placed in the form will be the one that will be addressed first, and the last control that was placed to the form will be the last to be addressed, using { For Each ctl In frm.Controls }