The following code will iterate through all text boxes in the Controls collection of the form for matching text.
Sub FindInControls(frm As Form, strSearch As String)
Dim ctl As Control
For Each ctl In frm.Controls
' Limit search to text boxes
If ctl.ControlType = acTextBox Then
If ctl.Value = strSearch Then
' Print the control name and value
' Change this to whatever functionality you need
Debug.Print ctl.Name, ctl.Value
The navigation buttons at the bottom of a form in Access 2007 includes a Search box which also does this for you.
Hope this helps,
Lead Software Design Engineer in Test
Microsoft Access Team
co-author: Access 2007 VBA Programmer's Reference
co-author: Expert Access 2007 Programming
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at microsoft.com/info/cpyright.htm.