wizcow
Registered User.
- Local time
- Today, 06:24
- Joined
- Sep 22, 2001
- Messages
- 236
This is a peice of code I adapted from Jack Austin.
My form has an unbound textbox where I enter search criteria. (txtSearch)
The search is performed on a memo textbox called (Notes)
The problem I have is that it will only search with in the record that is open.
Jack Austin's Access97 demo works properly. (it searches all records)
In my Access2000 it does not go to the next record, it searches only the open record.
I'm hoping one of you vb Guru's can look at this code and tell me whats wrong.
Thanks
Tom
My form has an unbound textbox where I enter search criteria. (txtSearch)
The search is performed on a memo textbox called (Notes)
The problem I have is that it will only search with in the record that is open.
Jack Austin's Access97 demo works properly. (it searches all records)
In my Access2000 it does not go to the next record, it searches only the open record.
I'm hoping one of you vb Guru's can look at this code and tell me whats wrong.
Code:
Option Compare Database
Option Explicit
Dim strSearch As String, intWhere As Integer
Private Sub Command74_Click()
On Error Resume Next
If IsNull(Me!Notes) Or IsNull(Me!txtSearch) Then Exit Sub
intWhere = Len(Me!txtSearch) 'find the length of the string in Notes
If strSearch = 0 Then strSearch = 1
strSearch = InStr(strSearch, Me!Notes, Me!txtSearch)
If strSearch > 0 Then
Me!Notes.SetFocus
Me!Notes.SelStart = strSearch - 1
Me!Notes.SelLength = intWhere
strSearch = strSearch + 1
Else
strSearch = 1
Dim rs As Recordset
Set rs = Me.Recordset
rs.Bookmark = Me.Bookmark '
rs.MoveNext
If rs.EOF Then
If MsgBox("You are at the end of the table, there are no more records to display." & vbCrLf & "Do you wish to search the records from the beginning for a different word or phrase?", vbDefaultButton2 + vbYesNo + vbQuestion, "What Is Your Pleasure?") = vbYes Then
rs.MoveFirst
Me.Bookmark = rs.Bookmark
Me!txtSearch = Null
Me!txtSearch.SetFocus
'TimeCounter = 0
Else
End If
Else
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End If
End Sub
Thanks
Tom