Search box to search from a subform query

Zuzu

Registered User.
Local time
Tomorrow, 03:28
Joined
Jun 2, 2015
Messages
29
Hello all

I am having some trouble with getting a search box to work on a search form.

Initially, the form was setup with the query on the main form, and the following code below returned the correct search results.

Code:
Dim strsearch As String
Dim Task As String

'Check if a keyword entered or not
If IsNull(Me.txtSearch) Or Me.txtSearch = "" Then
   MsgBox "Please type in your search keyword.", vbOKOnly, "Keyword Needed"
   Me.txtSearch.SetFocus
      
Else
   strsearch = Me.txtSearch.Value
   Task = "SELECT * FROM qryMemrSearch WHERE ((RequestorsName Like ""*" & strsearch & "*"") OR (Department Like ""*" & strsearch & "*"") OR (Section Like ""*" & strsearch & "*"") or (ContactNumber Like ""*" & strsearch & "*"") OR (JobContactName Like ""*" & strsearch & "*"") OR (JobDescription Like ""*" & strsearch & "*""))"
   Me.RecordSource = Task
   End If

However, i have now put the query as a subform on the main search form.

How do i change the vba code to reference the subform?
 
yoursubformcontrol.form.recordsource = task
 
Sorry... Still cannot get it to work.

I have attached a copy of the Search form - hoping that someone can show me where i am going wrong.

Cheers

Zuzu
 

Attachments

.recordset should be .recordsource
so the reference would be
Code:
Me.qryMemrSearch_subform.Form.RecordSource = Task
 
Static and Moke123

Thank you very much for the help...... really appreciated!!!
 

Users who are viewing this thread

Back
Top Bottom