oohmygod831
Registered User.
- Local time
- Today, 22:25
- Joined
- Feb 16, 2005
- Messages
- 43
i have a form for the user to book in tools, the list of tools are filtered through three cascading combo boxes.
My problem is this, i am using a query to calculate individual tool stock levels. now if i book tools in and run the query separately it works ok but i need the query to run automatically once the tool selection in the final combo box has been made.
I am using AfterUpdate and DLookup to access the data from the query but this way i get a Null value every time and ive no idea why.
this is a copy of the sql for the query:
SELECT tblToolBooking.Tool_ID, Sum(tblToolBooking.Book_Value) AS Out, tblTool.Tool_Name, tblTool.Factory_Stock, tblTool.Factory_Stock+[Out] AS StockTotal
FROM tblTool INNER JOIN (tblOperator INNER JOIN (tblMachine INNER JOIN tblToolBooking ON tblMachine.Machine_ID = tblToolBooking.Machine_ID) ON tblOperator.Operator_ID = tblToolBooking.Operator_ID) ON tblTool.Tool_ID = tblToolBooking.Tool_ID
GROUP BY tblToolBooking.Tool_ID, tblTool.Tool_Name, tblTool.Factory_Stock
HAVING (((tblToolBooking.Tool_ID)=[Forms]![frmBookInOut]![cboToolName]));
This is the code for the DLookup:
Private Sub cboToolName_AfterUpdate()
Dim bkValue As Integer
MsgBox "qryCheck returns --> " & DCount("*", "qryCheck")
bkValue = Nz(DLookup("StockTotal", "qryCheck", "Tool_ID = " & Forms![frmBookInOut]!Tool_ID), 0)
If bkValue < 1 Then
MsgBox "The tool is already booked out or hasn't been returned"
Cancel = True
Me.Undo
End If
End Sub
i used this code to check what the query was returning and it is always a Null value
MsgBox "qryCheck returns --> " & DCount("*", "qryCheck")
I have no idea where to start, any help would be gratefully recieved.
My problem is this, i am using a query to calculate individual tool stock levels. now if i book tools in and run the query separately it works ok but i need the query to run automatically once the tool selection in the final combo box has been made.
I am using AfterUpdate and DLookup to access the data from the query but this way i get a Null value every time and ive no idea why.
this is a copy of the sql for the query:
SELECT tblToolBooking.Tool_ID, Sum(tblToolBooking.Book_Value) AS Out, tblTool.Tool_Name, tblTool.Factory_Stock, tblTool.Factory_Stock+[Out] AS StockTotal
FROM tblTool INNER JOIN (tblOperator INNER JOIN (tblMachine INNER JOIN tblToolBooking ON tblMachine.Machine_ID = tblToolBooking.Machine_ID) ON tblOperator.Operator_ID = tblToolBooking.Operator_ID) ON tblTool.Tool_ID = tblToolBooking.Tool_ID
GROUP BY tblToolBooking.Tool_ID, tblTool.Tool_Name, tblTool.Factory_Stock
HAVING (((tblToolBooking.Tool_ID)=[Forms]![frmBookInOut]![cboToolName]));
This is the code for the DLookup:
Private Sub cboToolName_AfterUpdate()
Dim bkValue As Integer
MsgBox "qryCheck returns --> " & DCount("*", "qryCheck")
bkValue = Nz(DLookup("StockTotal", "qryCheck", "Tool_ID = " & Forms![frmBookInOut]!Tool_ID), 0)
If bkValue < 1 Then
MsgBox "The tool is already booked out or hasn't been returned"
Cancel = True
Me.Undo
End If
End Sub
i used this code to check what the query was returning and it is always a Null value
MsgBox "qryCheck returns --> " & DCount("*", "qryCheck")
I have no idea where to start, any help would be gratefully recieved.