I have made a form that has an unbound textbox and a command button and a datasheet subform.
The idea is that I can search for a PONumber (name of field) value and have it display all records with that PONumber.
I tried this code but it only displays the first record containing that PONumber value but not the rest (there could be anywhere from 1 to 8 or more.
I know I did something wrong... can someone please tell me what I am missing?
When I don't try to use the subform the code works displaying all records but I have to put the fields I want to see on the form... I would like to see all data in each record.
The purpose it for editing values in records without having to go into the tables
The idea is that I can search for a PONumber (name of field) value and have it display all records with that PONumber.
I tried this code but it only displays the first record containing that PONumber value but not the rest (there could be anywhere from 1 to 8 or more.
Code:
Private Sub cmdPOSearch_Click()
Dim strsearch As String
Dim Task As String
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 tbl_auditdata WHERE ((PONumber Like ""*" & strsearch & "*""))"
Me.RecordSource = Task
End If
End Sub
Private Sub Form_Load()
Dim Task As String
Task = "SELECT * FROM tbl_auditdata WHERE (status)is null"
Me.RecordSource = Task
Me.txtSearch.SetFocus
End Sub
I know I did something wrong... can someone please tell me what I am missing?
When I don't try to use the subform the code works displaying all records but I have to put the fields I want to see on the form... I would like to see all data in each record.
The purpose it for editing values in records without having to go into the tables