What I am trying to do is for the given part number in a subform, a query will run to add all quantities in all workorders for that part number. I have the code entered below, but keep getting a 'Type Mismatch' error. I have no idea where to go from here.
Private Sub Quantity_AfterUpdate()
DoCmd.RunCommand acCmdSaveRecord
Dim rst As Recordset
Dim db As Database
Dim strsql As String
strsql = "SELECT Sum(WorkorderDetails.Quantity) AS temp FROM WorkorderDetails WHERE PartNumber = '" & Me!PartNumber & "';"
Set db = CurrentDb
Set rst = db.OpenRecordset(strsql)
rst.MoveFirst
If rst!temp > 1 Then
MsgBox ("More that One"
Else
End If
rst.Close
End Sub
Private Sub Quantity_AfterUpdate()
DoCmd.RunCommand acCmdSaveRecord
Dim rst As Recordset
Dim db As Database
Dim strsql As String
strsql = "SELECT Sum(WorkorderDetails.Quantity) AS temp FROM WorkorderDetails WHERE PartNumber = '" & Me!PartNumber & "';"
Set db = CurrentDb
Set rst = db.OpenRecordset(strsql)
rst.MoveFirst
If rst!temp > 1 Then
MsgBox ("More that One"
Else
End If
rst.Close
End Sub