Hi all,
:banghead:
I have a form with a subform containing 'tbl_winestock' in datasheet view. On the form are some controls.
A text box (txt_searchproductname)
A command button (but_searchProductName)
When I enter text into the txt field and click the button, nothing happens. Focus is set to the first record in the subform datasheet.
Where on earth am I going wrong? I'm sure it's something simple.
Thanks very much for your help.
:banghead:
I have a form with a subform containing 'tbl_winestock' in datasheet view. On the form are some controls.
A text box (txt_searchproductname)
A command button (but_searchProductName)
When I enter text into the txt field and click the button, nothing happens. Focus is set to the first record in the subform datasheet.
Code:
Private Sub but_searchProductName_Click()
Dim strsearch As String
Dim Task As String
If IsNull(Me.txt_searchproductname) Or Me.txt_searchproductname = "" Then
MsgBox "Please type in your search criteria", vbOKOnly, "Keyword Needed"
Me.txt_searchproductname = vbYellow
Me.txt_searchproductname.SetFocus
Else
strsearch = Me.txt_searchproductname.Value
Task = "Select * From tbl_winestock where ((Product_Name Like ""*" & strsearch & "*""))"
Me.RecordSource = Task
Me.txt_searchproductname.BackColor = vbWhite
End If
End Sub
Where on earth am I going wrong? I'm sure it's something simple.
Thanks very much for your help.