goodhvnting
Registered User.
- Local time
- Today, 02:14
- Joined
- Sep 8, 2016
- Messages
- 10
Hello!
This is my first post asking for help in this awesome community so please bare with me as I try to explain my problem.
Problem:
I am hoping someone can help me with part of my code. I have check boxes and a search box that both work. My checkbox filters out results based on what is selected, and my search box can search multiple fields. The problem is when I try to combine both the checkbox and search box I lose the ability to search multiple fields in my search box.
Hopeful Outcome:
I would like my search box to search multiple fields using keywords but at the same time follow the rules of my checkboxes. Could someone take a look at my code? Currently the checkboxes only apply to field "Title" but I want it to also apply to search fields "Keywords" and "Comments". Any help would be very much appreciated! Cheers
Here is my code and I will also attach my db:
Private Sub Command637_Click()
'Check if search parameters exist
Dim strsearch As String
Dim strtext As String
Dim Task As String
Dim CRM As Integer
Dim RRM As Integer
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
Me.Refresh
strsearch = Me.txtSearch.Value
If Me.chkCRM = True Then
CRM = 1
End If
If Me.chkRRM = True Then
RRM = 2
End If
strsearch = Me.txtSearch.Value
Task = "SELECT * FROM tblResourceRoom WHERE ((([LocationID] = " _
& CRM & ") Or ([LocationID] = " _
& RRM & ")) And (Title like ""*" & strsearch & "*"") Or (Keywords like ""*" & strsearch & "*"") Or (Comments like ""*" & strsearch & "*""))"
Me.RecordSource = Task
End If
End Sub
Private Sub Command638_Click()
Dim strsearch As String
strsearch = "SELECT * from tblResourceRoom"
Me.RecordSource = strsearch
End Sub
Private Sub Command657_Click()
Me.chkCRM = False
Me.chkRRM = False
End Sub
Private Sub Command658_Click()
Me.chkCRM = True
Me.chkRRM = True
End Sub
Private Sub txtSearch_AfterUpdate()
Call Command637_Click
End Sub
This is my first post asking for help in this awesome community so please bare with me as I try to explain my problem.
Problem:
I am hoping someone can help me with part of my code. I have check boxes and a search box that both work. My checkbox filters out results based on what is selected, and my search box can search multiple fields. The problem is when I try to combine both the checkbox and search box I lose the ability to search multiple fields in my search box.
Hopeful Outcome:
I would like my search box to search multiple fields using keywords but at the same time follow the rules of my checkboxes. Could someone take a look at my code? Currently the checkboxes only apply to field "Title" but I want it to also apply to search fields "Keywords" and "Comments". Any help would be very much appreciated! Cheers

Here is my code and I will also attach my db:
Private Sub Command637_Click()
'Check if search parameters exist
Dim strsearch As String
Dim strtext As String
Dim Task As String
Dim CRM As Integer
Dim RRM As Integer
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
Me.Refresh
strsearch = Me.txtSearch.Value
If Me.chkCRM = True Then
CRM = 1
End If
If Me.chkRRM = True Then
RRM = 2
End If
strsearch = Me.txtSearch.Value
Task = "SELECT * FROM tblResourceRoom WHERE ((([LocationID] = " _
& CRM & ") Or ([LocationID] = " _
& RRM & ")) And (Title like ""*" & strsearch & "*"") Or (Keywords like ""*" & strsearch & "*"") Or (Comments like ""*" & strsearch & "*""))"
Me.RecordSource = Task
End If
End Sub
Private Sub Command638_Click()
Dim strsearch As String
strsearch = "SELECT * from tblResourceRoom"
Me.RecordSource = strsearch
End Sub
Private Sub Command657_Click()
Me.chkCRM = False
Me.chkRRM = False
End Sub
Private Sub Command658_Click()
Me.chkCRM = True
Me.chkRRM = True
End Sub
Private Sub txtSearch_AfterUpdate()
Call Command637_Click
End Sub