Hi There,
I have a form which I use to add stock to the stock table. It uses the following code to do this:
This code on its own works without issues. I have since then added a query that summaries the contents of my stock table and shows me only the unique record and gives a quantity of how many there are. For example I have 5 keyboards in my stock table each with a unique ID. This query shows me a table showing only one row for keyboards but gives a value in the quantity column of 5. For some reason this query effects my above add stock code and causes a blank record to be added into the stock table evrytime I add stock. Why might this be please and how do I prevent it? The SQL for my summary query is as follows:
Kind regards,
Dom
I have a form which I use to add stock to the stock table. It uses the following code to do this:
Code:
Private Sub btnAdd_Click()
Dim iCtr As Integer
'Calculates how many entries to put into the table based on value in txtQty
For iCtr = 1 To Me.txtQty
'Adds all fields into the stock table
CurrentDb.Execute "INSERT INTO Stock (Item, Make, Model, Cost, DatePurchased, WarrantyPeriod) VALUES ('" & Me.txtItem & "','" & Me.cboMake & "','" & Me.cboModel & "','" & Me.txtCost & "','" & Me.txtDate & "','" & Me.cboWarranty & "')"
Next
'Clears all data fields
Me!txtItem = Null
Me!cboMake = Null
Me!cboModel = Null
Me!txtCost = "0.00"
Me!txtQty = Null
Me!txtDate = Null
Me!cboWarranty = Null
Me.cboMake.Requery
Me.cboModel.Requery
End Sub
Code:
SELECT Stock.Item, Stock.Make, Stock.Model, Count(Stock.ID) AS Quantity
FROM Stock
GROUP BY Stock.Item, Stock.Make, Stock.Model;
Kind regards,
Dom