Paul said:
How to make Access Not to evaluate the "On Change" event on a combo box if
the user enter space. For example "Paul ". Thanks.
The following are the two events attached to the cboProduct, it works on
every character and refresh the subform EXCEPT the Space like "Paul ". It
removes the Ending Space if I enter a space after a character. for example I
entered a space after "Paul ", it becomes "Paul" and it will not retain the
space after the character "l"
Private Sub cboProduct_Change()
Dim KeyAscii As Integer
Me.btnClose.SetFocus
Refresh
If IsNull(Me.cboProduct) Or Me.cboProduct = "" Then
Forms![Frm_Quick Search]![Frm_Quick Search
Subform].Form.RecordSource = ""
Forms![Frm_Quick Search]![Frm_Quick Search
Subform].Form![Product].ControlSource = ""
Forms![Frm_Quick Search]![Frm_Quick Search
Subform].Form![StockNumber].ControlSource = ""
Forms![Frm_Quick Search]![Frm_Quick Search
Subform].Form![PotSize].ControlSource = ""
Forms![Frm_Quick Search]![Frm_Quick Search
Subform].Form![Location].ControlSource = ""
Forms![Frm_Quick Search]![Frm_Quick Search
Subform].Form![StockNumberNotes].ControlSource = ""
Forms![Frm_Quick Search]![Frm_Quick Search
Subform].Form![Quantity].ControlSource = ""
Me.cboProduct.SetFocus
Requery
Refresh
Else
Forms![Frm_Quick Search]![Frm_Quick Search
Subform].Form.RecordSource = "SELECT Tbl_Product.Product,
Tbl_Inventory.StockNumber, Tbl_Inventory_Detail.PotSize,
Tbl_Inventory_Detail.Location, Sum(Tbl_Inventory_Detail.Quantity) AS
SumOfQuantity, Tbl_Inventory_Detail.StockNumberNotes " & _
"FROM (Tbl_Product INNER JOIN Tbl_Inventory ON Tbl_Product.ProductID
= Tbl_Inventory.ProductID) INNER JOIN Tbl_Inventory_Detail ON
Tbl_Inventory.InventoryID = Tbl_Inventory_Detail.InventoryID " & _
"GROUP BY Tbl_Product.Product, Tbl_Inventory.StockNumber,
Tbl_Inventory_Detail.PotSize, Tbl_Inventory_Detail.Location,
Tbl_Inventory_Detail.StockNumberNotes " & _
"HAVING (((Tbl_Product.Product) Like """ & [Forms]![Frm_Quick
Search]![cboProduct] & "*" & """));"
Forms![Frm_Quick Search]![Frm_Quick Search
Subform].Form![Product].ControlSource = "Product"
Forms![Frm_Quick Search]![Frm_Quick Search
Subform].Form![StockNumber].ControlSource = "StockNumber"
Forms![Frm_Quick Search]![Frm_Quick Search
Subform].Form![PotSize].ControlSource = "PotSize"
Forms![Frm_Quick Search]![Frm_Quick Search
Subform].Form![Location].ControlSource = "Location"
Forms![Frm_Quick Search]![Frm_Quick Search
Subform].Form![StockNumberNotes].ControlSource = "StockNumberNotes"
Forms![Frm_Quick Search]![Frm_Quick Search
Subform].Form![Quantity].ControlSource = "SumOfQuantity"
Me.cboProduct.SetFocus
Refresh
Me.cboProduct.SelStart = Len(Me.cboProduct) + 1
End If
End Sub
Private Sub cboProduct_KeyPress(KeyAscii As Integer)
If InStr("\/:*?-_""< >", Chr(KeyAscii)) > 0 Then
Exit Sub
Else
cboProduct_Change
End If
End Sub