MS ACCESS: SEARCH in a split form

Joined
Apr 3, 2017
Messages
1
Reaction score
0
Hi,

I have a split form here and I want to maximize my searching in the Form currently I have 1 search field where you input a keyword and displays the record set based on the keyword. Now, I wanted to add a date range to maximize my searching however the code doesn't work in my end. here's my vba code.

Dim strsearch As String
Dim Task1, Task2 As String
Dim strCriteria 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.BackColor = vbYellow
Me.txtsearch.SetFocus
Else
strsearch = Me.txtsearch.Value
strCriteria = "([DateAddedtoTracker] >= #" & Me.txtdate1 & "# And [DateAddedtoTracker] <= #" & Me.txtdate2 & "#)"
Task1 = "SELECT * FROM NLTREG WHERE ((State Like ""*" & strsearch & "*"") or (Federal Like ""*" & strsearch & "*"") or (GSEType Like ""*" & strsearch & "*"") or (Subject Like ""*" & strsearch & "*"") or (ItemNo Like ""*" & strsearch & "*"") or (LawTitle Like ""*" & strsearch & "*"") or (AdditionalComments Like ""*" & strsearch & "*"") or (Summary Like ""*" & strsearch & "*"")) order by ItemNo"
Task2 = "Select * from NLTREG where (" & strCriteria & ") order by [DateAddedtoTracker]"
Me.RecordSource = Task1
Me.RecordSource = Task2

Me.txtsearch.BackColor = vbWhite
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top