G
Guest
I'm creating a tracking database and have a subform within a form that I want
to create a search textbox and command button. I'm able to search off of one
field within the form but do not know how to code the search for the subform.
The two forms are as follows: frmAuditTracking, fsubPurchases. The two fields
are as follows: Forms.frmAuditTracking.txtPSR, Forms.fsubPurchases.txtReqID.
In addition, I would also like to find multiple records with the same search
criteria and not just the first record found.
Here's the code I have so far...
Private Sub cmdSearch_Click()
Dim strPSR As String
Dim strSearch As String
If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
MsgBox "Please enter a PSR/REQ.", vbOKOnly
Me![txtSearch].SetFocus
Exit Sub
End If
DoCmd.ShowAllRecords
DoCmd.GoToControl ("txtPSR")
DoCmd.FindRecord Me!txtSearch
txtPSR.SetFocus
strPSR = txtPSR.Text
txtSearch.SetFocus
strSearch = txtSearch.Text
If strPSR = strSearch Then
MsgBox "Found PSR/REQ " & strSearch & "."
txtPSR.SetFocus
txtSearch = ""
Else
MsgBox "PSR/REQ " & strSearch & " not found."
txtSearch.SetFocus
End If
End Sub
Any help would be greatly appreciated. Thanks.
James
to create a search textbox and command button. I'm able to search off of one
field within the form but do not know how to code the search for the subform.
The two forms are as follows: frmAuditTracking, fsubPurchases. The two fields
are as follows: Forms.frmAuditTracking.txtPSR, Forms.fsubPurchases.txtReqID.
In addition, I would also like to find multiple records with the same search
criteria and not just the first record found.
Here's the code I have so far...
Private Sub cmdSearch_Click()
Dim strPSR As String
Dim strSearch As String
If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
MsgBox "Please enter a PSR/REQ.", vbOKOnly
Me![txtSearch].SetFocus
Exit Sub
End If
DoCmd.ShowAllRecords
DoCmd.GoToControl ("txtPSR")
DoCmd.FindRecord Me!txtSearch
txtPSR.SetFocus
strPSR = txtPSR.Text
txtSearch.SetFocus
strSearch = txtSearch.Text
If strPSR = strSearch Then
MsgBox "Found PSR/REQ " & strSearch & "."
txtPSR.SetFocus
txtSearch = ""
Else
MsgBox "PSR/REQ " & strSearch & " not found."
txtSearch.SetFocus
End If
End Sub
Any help would be greatly appreciated. Thanks.
James