Hi all, I have a search button on my form and when I click on search it is unable to show only the data that I search.
Below is my coding:
Below is my coding:
Code:
Private Sub txtSearch_Click()
'declare variable
Dim sql As String
'Determine and return the number of records in UnmatchFabricPOqry
If DCount("*", "UnmatchNewFabricPOQry", "PO like '*" & Me.txtKeyword & "*'") = 0 Then
'Error message will be display if PO number is not found
MsgBox "No record found,check your PO again!"
Else
'If PO number is found, it will retrive the data below from UnmatchFabricPOqry
sql = "SELECT UnmatchNewFabricPOQry.PO, UnmatchNewFabricPOQry.Date, UnmatchNewFabricPOQry.[Style NO], UnmatchNewFabricPOQry.[GL Lot], UnmatchNewFabricPOQry.PO, UnmatchNewFabricPOQry.[Fabric Cuttable Width], UnmatchNewFabricPOQry.Color, UnmatchNewFabricPOQry.[Our Qty], UnmatchNewFabricPOQry.[Supplier Qty],UnmatchNewFabricPOQry.GSMBeforeWash, UnmatchNewFabricPOQry.Description2, UnmatchFabricPOqry.[GMS Per SqYD], UnmatchNewFabricPOQry.[Remark],UnmatchNewFabricPOQry.[Fabric Weight], UnmatchNewFabricPOQry.[Unit Price],UnmatchNewFabricPOQry.ShipName,UnmatchNewFabricPOQry.[Garment Delivery Date],UnmatchNewFabricPOQry.POStatus, UnmatchNewFabricPOQry.[PO Amend No], UnmatchNewFabricPOQry.GSMAfterWash" _
& " FROM UnmatchNewFabricPOQry " _
& " WHERE PO LIKE '*" & Me.txtKeyword & "*' "
'Click on search button to refresh data
Me.Lst_PO.Recordset = strSQL
Me.Lst_PO.Requery
End If
End Sub