I have a very successful code,built by the way with the help of the Forum, which runs as follwos:
Dim city As Long
Select Case Forms![FOrderInformation]![office] ‘ this is an Option Box called Office, with 8 options
Case 1
city = 0
Case 2
city = 1
Case 3
city = 2
Case 4
city = 3
Case 5
city = 4
Case 6
city = 5
Case 7
city = 6
Case 8
city = 7
End Select
Dim MySubform As Form
Set MySubform = [Forms]![FOrderInformation]![Forder details extended].[Form]
Dim StrCartons As String
StrCartons = [Forms]![FOrderInformation]![Forder details extended].[Form].[cartons]
StrItems = [Forms]![FOrderInformation]![Forder details extended].[Form].[items]
Dim strSQL As String
Dim strWhere As String
strWhere = ” WHERE ProductID=” & MySubform.Productid
strSQL = “UPDATE Products SET ” & _
” products.branch” & city & ” = products.branch” & city & ” – ” & StrCartons & strWhere
DoCmd.RunSQL strSQL ‘ substract
I want to improve my code and place a “brake’ in the code in case the stock is depleted.
it means that one should not be allowed to order if the goods are not on stock.
I have tried the following line:
If products.branch” & city & ” – StrCartons < 0 then
MsgBox "There isn't enough stock to fill this order.", vbInformation + vbOKOnly
These lines however are not accepted by Access.Is there a way to place these line in my above working code?