goodhvnting
Registered User.
- Local time
- Today, 05:03
- Joined
- Sep 8, 2016
- Messages
- 10
Hello!
This is my 3rd time posting in this wonderful and supportive community. My first two questions have been solved and I am back hoping to build on what i've already learned.
Problem:
I have a main form with a subform that displays records. In the main form I have an unbound text box with 2 buttons called "search" and "show all". My problem is I cannot figure out the right code so that if a search term is entered into the text box the results would populate in the subform. In addition to, if a user clicks on the "show all" button, all records would be displayed in the subform.
Please let me know if it would help to post the DB. I know I am missing some important statements but my knowledge is minimal that I can't figure it out.
Here is the code I have been playing with:
Property Get WhereTextSearch() As String
If Not IsNull(Me.txtSearch2) Or Me.txtSearch2 = "" Then
WhereTextSearch = _
"(FileNumber like ""*" & Me.txtSearch2 & "*"") " & _
"Or (FileTitle like ""*" & Me.txtSearch2 & "*"") " & _
"Or (Notes like ""*" & Me.txtSearch2 & "*"") " & _
"Or (DateOpened like ""*" & Me.txtSearch2 & "*"")"
End If
End Property
Private Sub SetSubformRecordSource()
Me.tblRecords_subform.Form.RecordSource = "SELECT * FROM tblRecords " & Me.WhereTextSearch
End Sub
Private Sub Command11_Click()
SetSubformRecordSource
End Sub
Private Sub Command12_Click()
SetSubformRecordSource
End Sub
Private Sub txtSearch2_AfterUpdate()
Call Command11_Click
End Sub
This is my 3rd time posting in this wonderful and supportive community. My first two questions have been solved and I am back hoping to build on what i've already learned.
Problem:
I have a main form with a subform that displays records. In the main form I have an unbound text box with 2 buttons called "search" and "show all". My problem is I cannot figure out the right code so that if a search term is entered into the text box the results would populate in the subform. In addition to, if a user clicks on the "show all" button, all records would be displayed in the subform.
Please let me know if it would help to post the DB. I know I am missing some important statements but my knowledge is minimal that I can't figure it out.
Here is the code I have been playing with:
Property Get WhereTextSearch() As String
If Not IsNull(Me.txtSearch2) Or Me.txtSearch2 = "" Then
WhereTextSearch = _
"(FileNumber like ""*" & Me.txtSearch2 & "*"") " & _
"Or (FileTitle like ""*" & Me.txtSearch2 & "*"") " & _
"Or (Notes like ""*" & Me.txtSearch2 & "*"") " & _
"Or (DateOpened like ""*" & Me.txtSearch2 & "*"")"
End If
End Property
Private Sub SetSubformRecordSource()
Me.tblRecords_subform.Form.RecordSource = "SELECT * FROM tblRecords " & Me.WhereTextSearch
End Sub
Private Sub Command11_Click()
SetSubformRecordSource
End Sub
Private Sub Command12_Click()
SetSubformRecordSource
End Sub
Private Sub txtSearch2_AfterUpdate()
Call Command11_Click
End Sub