I have an order form in which I select parts/items from a listbox (lstItemsPerVendor), relating to a specific Vendor, to be ordered and then adjust the quantity and purchase price in the subform (frmOrderItemsPerID). However, I have also made the form allow for specific categories of parts to be selected for an easier search.
When not using a specific category, everything works great. However, if I select a category from the combobox and then change it, the items in the subform refresh because of the vba code and are no longer visible. Same if I use the "List all Parts" button. Shouldn't the Refresh still run the query that the subform is based off of if the rest of the mainform information is still present? The query criteria is on the mainform. My thought is that I should adjust the code for the combobox and button but I'm not sure how to go about writing it.
Here is my code below for one part:
Thank you!
When not using a specific category, everything works great. However, if I select a category from the combobox and then change it, the items in the subform refresh because of the vba code and are no longer visible. Same if I use the "List all Parts" button. Shouldn't the Refresh still run the query that the subform is based off of if the rest of the mainform information is still present? The query criteria is on the mainform. My thought is that I should adjust the code for the combobox and button but I'm not sure how to go about writing it.
Here is my code below for one part:
Code:
Private Sub cboFilterCategory_Change()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim sqlString As String
Set db = CurrentDb()
Set qdf = db.QueryDefs("qryItemsPerVendor")
qdf.SQL = "SELECT Items.ItemID, Items.ItemName, Items.Brand, Items.[Product#], Items.QtyPerPackage, Items.RegPrice, Items.VendorID, Items.CategoryID " & "FROM [Items]" & "WHERE (((Items.VendorID)=[Forms]![frmInventoryOrders]![cboVendorName]) AND ((Items.CategoryID)=[Forms]![frmInventoryOrders]![cboFilterCategory]));"
Me.lstItemsPerVendor.Requery
Me.Refresh
qdf.Close
End Sub
Thank you!