I have various ways of stock leaving, but at the moment I can put a stock out even if there is no stock.
So I need some find of error message constraint to stop this being possible
so an example would be stockout 1x211070/11 warehouse1- 211070/11 (no stock)warehouse1 so the user has to stockout from warehouse2
On stock control form I have a field that shows stock in warehouse1 and warehouse2
Best way to do this??
Thanks
New minor calculation
-
- Administrator
- Posts: 78421
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: New minor calculation
With the design of the database you e-mailed earlier: create a Before Update event for the StockOut text box on the subform:
Code: Select all
Private Sub StockOut_BeforeUpdate(Cancel As Integer)
Dim lngStock As Long
If IsNull(Me.Location) Then
MsgBox "Select a location first!", vbExclamation
Cancel = True
Exit Sub
End If
Select Case Me.Location
Case "1"
lngStock = Nz(Me.Parent.[At Delamode], 0)
Case "2"
lngStock = Nz(Me.Parent.[At Wearhouse], 0)
End Select
If Me.NewRecord Then
If Me.StockOut > lngStock Then
MsgBox "You can take out at most " & lngStock, vbExclamation
Cancel = True
End If
End If
End Sub
Best wishes,
Hans
Hans
-
- StarLounger
- Posts: 73
- Joined: 08 Jan 2012, 15:07
Re: New minor calculation
I take it you took th9is right from the database i sent you?
I copied and pasted this into the before as you say and am getting run time error '2465;
mircosoft cant find the field ' 1' (might be a 'l') referred to in your expression
I copied and pasted this into the before as you say and am getting run time error '2465;
mircosoft cant find the field ' 1' (might be a 'l') referred to in your expression
-
- Administrator
- Posts: 78421
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: New minor calculation
I have attached a much reduced version of your database. Try it for example in record # 51 on the main form (stock code 211070/35). At Delamode has 171 items.
Activate the Activity tab, enter 1 in the Location field in the subform, then enter 200 (or any number larger than 171) in the Stockout field and press Tab.
Activate the Activity tab, enter 1 in the Location field in the subform, then enter 200 (or any number larger than 171) in the Stockout field and press Tab.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans