TheEvilSam
Registered User.
- Local time
- Today, 13:02
- Joined
- Jan 23, 2012
- Messages
- 13
I have a query as follows
It all seems to work, but even when the value for the txt box is nul, it still continues with the doCmd bits. I only want the 6 lines of commands to run if the value is not null, but it keeps turning up error codes when the value is null.
Any Ideas?
Thanks
Sam
Ps, when not null, it is now saying there is a missing semicolon at the end of the SQLStore
Code:
Private Sub StockOK_Click()
Dim SQLDelete1 As String
Dim SQLDelete2 As String
Dim SQLUpdate As String
Dim SQLStore As String
SQLDelete1 = "DELETE * FROM TblStock WHERE TblStock.ProductID = " & CboStockItem.Value
SQLDelete2 = "DELETE * FROM TblTotalSale WHERE TblTotalSale.ProductID = " & CboStockItem.Value
SQLUpdate = "INSERT INTO TblStock (ProductID, StockLevel) VALUES ( " & Me.CboStockItem.Value & "," & Me.TxtStockValue & " )"
SQLStore = "INSERT INTO TblSaleStore (ProductID, Item) VALUES ProductID, Item From TblTotalSale WHERE TblTotalSale.ProductID = " & CboStockItem.Value
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.SetWarnings False
DoCmd.RunSQL SQLStore
DoCmd.RunSQL SQLDelete2
DoCmd.RunSQL SQLUpdate
DoCmd.SetWarnings True
End Sub
Any Ideas?
Thanks
Sam
Ps, when not null, it is now saying there is a missing semicolon at the end of the SQLStore
Last edited: