title: Combobox referencing access 2010 query
body: <p>I have a form with a combo box which is linked to a table (TblProduct)which show the product description and is ordered by the product ID</p>
  
  <p>I also have a text box called txtStockValue.</p>
  
  <p>I want users to select the product form the combo box, do a stock count and input the stock value in the txtStockValue box.</p>
  
  <p>There is then a button which confirms the update.</p>
  
  <p>I have the following coding for the button, but I put the problem in this section of the forum because I think my problem is in the query... I have never used combo boxes before</p>
  
  <p>the coding is as follows</p>
  
  <pre><code>Private Sub StockOK_Click()
  Dim SQLDelete1 As String
  Dim SQLDelete2 As String
  Dim SQLUpdate As String
  
  SQLDelete1 = "DELETE * FROM TblStock WHERE TblStock.ProductID = CboStockItem.ProductID"
  SQLDelete2 = "DELETE * FROM TblTotalSales WHERE TblTotalSales.ProductID = CboStockItem.ProductID"
  SQLUpdate = "INSERT INTO TblStock (ProductID, StockLevel) SELECT ProductID FROM CboStockItem.ProductID AND SELECT StockLevel FROM TxtStockValue"
  
  If IsNull(Me.TxtStockValue) Then MsgBox "Please Select An Item To Update Stock And Ensure A Value Has Been Entered" Else:
  DoCmd.RunSQL SQLDelete1
  DoCmd.RunSQL SQLDelete2
  DoCmd.RunSQL SQLUpdate
  
  End Sub
  </code></pre>
  
  <p>I tried to reference the combo box as CboStockItem (The name of the combo box) but I don't think I have done this correctly.</p>
  
  <p>The code is basically supposed to delete all the items form 2 tables where the items ID is the same as in the product selected from the combo box and then insert the new value for stock into the stock table.</p>
  
  <p>A secondary point is that before the data is deleted it should be updated into two excel files for storage (a stock Excel file called Stock and a sales Excel file called sales). This I think I can do, but I thought to include it for interest.</p>