JForbes and Adezii
The data source is a Query (qryMainTableInput) pulling data tblMainTable based on what is inputted in a Form (frmMainFormInput)
Query SQL below
- SELECT tblMainTable.ItemID, tblMainTable.FiscalYear, tblMainTable.StoreName, tblMainTable.Item, tblMainTable.ItemDescription, tblMainTable.AuthQty, tblMainTable.GEOLOC, tblMainTable.GEOLOCName
-
FROM tblMainTable
-
WHERE (((tblMainTable.FiscalYear)=[Forms]![frmMainFormInput]![txtFiscalYear]) AND ((tblMainTable.StoreName)=[Forms]![frmMainFormInput]![cboStoreName]) AND ((tblMainTable.Item)=[Forms]![frmMainFormInput]![cboItem])) OR (((tblMainTable.FiscalYear)=[Forms]![frmMainFormInput]![txtFiscalYear]) AND ((tblMainTable.StoreName)=[Forms]![frmMainFormInput]![cboStoreName]) AND (([Forms]![frmMainFormInput]![cboItem]) Is Null)) OR (((tblMainTable.FiscalYear)=[Forms]![frmMainFormInput]![txtFiscalYear]) AND ((tblMainTable.Item)=[Forms]![frmMainFormInput]![cboItem]) AND (([Forms]![frmMainFormInput]![cboStoringName]) Is Null)) OR (((tblMainTable.FiscalYear)=[Forms]![frmMainFormInput]![txtFiscalYear]) AND (([Forms]![frmMainFormInput]![cboItem]) Is Null) AND (([Forms]![frmMainFormInput]![cboStoringName]) Is Null));
-
The Subform (SubfromStoreItemSearch) for frmMainFormInput is based off of the Query Results (SQL above) based on the inputs of unbound text/combo boxes in frmMainFormInput.
Created a Query button on frmMainFormInput to requery SubfromStoreItemSearch.
- Private Sub cmdbtnQuery_Click()
-
' Query Command Button
-
Me.subformStoreItemSearch.Requery
-
End Sub
-
This Command button works with no issue, user is allowed to change the unbound text/combo boxes manually and requery the subform to show the results in the subform. However; when I inserted the below code for a Clear the fields in the frmMainFormInput so the user do not have to manually clear the text and combo boxes in frmMainFromInput and reset for a new query
- Private Sub cmdbtnClear_Click()
-
'When button is clicked clears the field on the main form
-
Me.txtFiscalYear = ""
-
Me.cboStoreName = ""
-
Me.cboItem = ""
-
Me.txtItemName = ""
-
Me.cboStoreLocation = ""
-
Me.txtState = ""
-
Me.txtCity = ""
-
-
'Requery subform
-
Me.SubfromStoreItemSearch.Requery
-
Me.subformStoreItemSearch.SetFocus
-
DoCmd.GoToRecord , , acLast
-
Me.txtFicalYear.SetFocus
-
-
End Sub
Clear command button works, however; when user types in new info to Query (by Fiscal Year, Store Name, Item) and the user hits the Query Command Button the subform remains blank. But; when I go into the actual query (qryMainTableInput) the results show up. Or If the user exits out of the frmMainFromInput and re-opens the form the user can use the query button to populate the subform results. (until the clear command is executed).
Is their something wrong w/ the Clear Command Button VBA where it the form is not resetting for the user to query. Should I just delete the Clear Command Button and have the User just manually clear the form to query new info.
Hope this is clear as mud
Thanks