I have a form with a Search box and button at top.
The Detail section shows fields 1 and 3 over and over with the various records.
The search button has this code:
It works, but WOW, I wish there were a [detail field 1](index).SetFocus command to go directly to the record, and the fact that this works under ideal conditions.
Any suggestions?
The Detail section shows fields 1 and 3 over and over with the various records.
The search button has this code:
Code:
Private Sub cmdSearch_Click()
Dim rstTable1 As Recordset
Dim strSearchString As String
txtSearchString.SetFocus
strSearchString = txtSearchString.Text
Set rstTable1 = CurrentDb.OpenRecordset("Table1")
[detail field 1].SetFocus
Do While Not rstTable1.EOF
If (InStr(rstTable1.Fields("field1").Value, strSearchString) <> 0) Then
GoTo ending
End If
SendKeys "{DOWN}"
If (InStr(rstTable1.Fields("field3").Value, strSearchString) <> 0) Then
GoTo ending
End If
SendKeys "{DOWN}"
rstTable1.MoveNext
Loop
ending:
rstTable1.Close
SendKeys "{UP}"
End Sub
It works, but WOW, I wish there were a [detail field 1](index).SetFocus command to go directly to the record, and the fact that this works under ideal conditions.
Any suggestions?