Search in continuous form problem (1 Viewer)

Atthe

Member
Local time
Today, 17:17
Joined
Oct 26, 2021
Messages
57
Hi,

I have created a form which emulates a split form following the example database found here


This works fine however when I am trying to implement a search function with the following code I get one match in the text box's but the continuous form does not filter to show if there are multiple matches (Ie it shows all records)

Code:
    Me.SearchItem.SetFocus
    Me.FilterOn = False
    Me.Filter = "[SearchItem] Like '*" & SearchItem & "*'"
    Me.FilterOn = True
    Me.Requery

Can anyone help?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:17
Joined
May 7, 2009
Messages
19,169
have you tried it on Real Split form?
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:17
Joined
Sep 21, 2011
Messages
14,044
So you have to apply the same filter to the subform?, or perhaps just assign the form recordset again?
I am in a car park atm, but am sure I did this on one of my esf forms. Will check when I get home.
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:17
Joined
Sep 21, 2011
Messages
14,044
This is how I did it
Code:
Private Sub txtFilter_AfterUpdate()
Me.Filter = "Client Like ""*" & Me.txtFilter & "*"""
Me.FilterOn = True
Set Me.sfrmEmails.Form.Recordset = Me.Recordset
End Sub

and to clear
Code:
Private Sub cmdClearFilter_Click()
Me.Filter = ""
Me.txtFilter = ""
Me.FilterOn = False
Set Me.sfrmEmails.Form.Recordset = Me.Recordset
DoCmd.RunCommand acCmdRecordsGoToLast
DoCmd.GoToRecord acDataForm, Me.Name, acPrevious, 5 ' Needed for a continuous form as only last record shows.
DoCmd.RunCommand acCmdRecordsGoToLast

End Sub
The record movement is not needed for you most likely. I just wanted to see a few records in my subform.

HTH
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:17
Joined
Oct 29, 2018
Messages
21,358
Hi. If you need more help, you might consider posting a sample copy of your db. Just a thought...
 

Atthe

Member
Local time
Today, 17:17
Joined
Oct 26, 2021
Messages
57
This is how I did it
Code:
Private Sub txtFilter_AfterUpdate()
Me.Filter = "Client Like ""*" & Me.txtFilter & "*"""
Me.FilterOn = True
Set Me.sfrmEmails.Form.Recordset = Me.Recordset
End Sub

and to clear
Code:
Private Sub cmdClearFilter_Click()
Me.Filter = ""
Me.txtFilter = ""
Me.FilterOn = False
Set Me.sfrmEmails.Form.Recordset = Me.Recordset
DoCmd.RunCommand acCmdRecordsGoToLast
DoCmd.GoToRecord acDataForm, Me.Name, acPrevious, 5 ' Needed for a continuous form as only last record shows.
DoCmd.RunCommand acCmdRecordsGoToLast

End Sub
The record movement is not needed for you most likely. I just wanted to see a few records in my subform.

HTH

Thanks a lot this is perfect
 

Users who are viewing this thread

Top Bottom