Search subform for a word or phrase

Bobp3114

Member
Local time
Today, 10:14
Joined
Nov 11, 2020
Messages
69
I have a form (frmContactDetailsPower) with a form (frmProgressiveNotesEntryPower) linked by [StationID] from txtStationID. Form frmProgressiveNotesEntryPower is linked to a table (tblProgressiveNotes). I need to be able to search the table (limited by the StationID) for each instance of a word or phrase to locate a particular record.
At present I am converting the records to Word an using that search ability. Is there a quicker, better way to accomplish this?
Thanks, Bob
 
I am thinking you might be able to use a query. For example,

SQL:
SELECT * FROM TableName WHERE NotesID=1 AND NotesField Like "*searchword*"
 
maybe a sample will help (or confuse?) you.
see the Click event of search button.
 
i forget the sample demo, here it is.
Hi
I have adapted your code to suit, and it works to find the first matching record...how do I get it to move to the next matching record
This form is not a subform but one that opens with an ID from the previous form
Here is my code:
Private Sub cmdSearch_Click()
On Error GoTo Err_cmdSearch_Click
Dim sobForm As Form

Set sobForm = Forms("frmProgressiveNotesEntryRF")
If Len(Me.txtSearch & "") <> 0 Then
With sobForm.RecordsetClone
If Me.cmdSearch.Caption = "Submit Search" Then
.FindFirst "Notes Like '*" & Replace$(Me!txtSearch, "'", "''") & "*'"
If Not .NoMatch Then
sobForm.Bookmark = .Bookmark
Me.cmdSearch.Caption = " "
Else
MsgBox "No matching record found"
End If
Else
.Bookmark = sobForm.Bookmark
.FindNext "Notes Like '*" & Replace$(Me!txtSearch, "'", "''") & "*'"
If .NoMatch Then
Me.cmdSearch.Caption = "Submit Search"
MsgBox "No more matching record"
Else
sobForm.Bookmark = .Bookmark
End If
End If
End With
Else
MsgBox "please type something to search."
Me.txtSearch.SetFocus
End If
Exit_cmdSearch_Click:
Exit Sub

Err_cmdSearch_Click:
MsgBox Err.Description
Resume Exit_cmdSearch_Click
End Sub
 
The Access GUI provides search features. You don't need code or queries. Click into the field you want to search and press the binoculars to bring up the search dialog.
 

Users who are viewing this thread

Back
Top Bottom