M
Meilu
Hi,
My question is sort of a Query and a programming question.
I have two tables: tblColorOrders AND a
tblColorOrderDetails
I have two corresponding forms: frmColorOrders ANd
frmColorOrderDetails.
The second being a subform of the first.
ColorOrders has:
ID field, and a Qty Field
ColorOrderDetails connects to ColorOrders via the ID
field. ColorOrderDetails also has a Qty Field.
I've been trying to run a check that would compare the
sum of all the corresponding QTY's of ColorOrderDetails
to that of ColorOrders.
So I wrote the following to run on the "On Exit" even
frmColorOrderDetails. (It's a little simplified for
testing purposes... )
Private Sub frmColorOrderDetails_Exit(Cancel As Integer)
Dim db As Database
Dim rec As Recordset
Dim strQry As String
Dim strMsg As String
Dim tempQty As Integer
strQry = "Select Sum(tblColorOrderDetails.Qty) AS
[Qty] From tblColorOrderDetails " _
& " Where tblColorOrderDetails.LinkID = " &
Me!RecID
Set db = CurrentDb()
Set rec = db.OpenRecordset(strQry)
If (rec!Qty = 0) Then
If MsgBox("Uh Oh", vbOKCancel, "UH OH") = vbOK
Then
Debug.Print "It's a 0"
End If
ElseIf rec!Qty <> Me!Qty Then
If MsgBox("CHANGE IT NOW", vbOKOnly, "CHANGE") =
vbOK Then
DoCmd.CancelEvent
End If
Else
Debug.Print "Do Nothing"
End If
End Sub
The problem is that if the Qty in the subform is anything
but '0', the "CHANGE IT NOW" msg box pops up!
I'd appreciate ANY HELP!
Thanks,
Meilu
My question is sort of a Query and a programming question.
I have two tables: tblColorOrders AND a
tblColorOrderDetails
I have two corresponding forms: frmColorOrders ANd
frmColorOrderDetails.
The second being a subform of the first.
ColorOrders has:
ID field, and a Qty Field
ColorOrderDetails connects to ColorOrders via the ID
field. ColorOrderDetails also has a Qty Field.
I've been trying to run a check that would compare the
sum of all the corresponding QTY's of ColorOrderDetails
to that of ColorOrders.
So I wrote the following to run on the "On Exit" even
frmColorOrderDetails. (It's a little simplified for
testing purposes... )
Private Sub frmColorOrderDetails_Exit(Cancel As Integer)
Dim db As Database
Dim rec As Recordset
Dim strQry As String
Dim strMsg As String
Dim tempQty As Integer
strQry = "Select Sum(tblColorOrderDetails.Qty) AS
[Qty] From tblColorOrderDetails " _
& " Where tblColorOrderDetails.LinkID = " &
Me!RecID
Set db = CurrentDb()
Set rec = db.OpenRecordset(strQry)
If (rec!Qty = 0) Then
If MsgBox("Uh Oh", vbOKCancel, "UH OH") = vbOK
Then
Debug.Print "It's a 0"
End If
ElseIf rec!Qty <> Me!Qty Then
If MsgBox("CHANGE IT NOW", vbOKOnly, "CHANGE") =
vbOK Then
DoCmd.CancelEvent
End If
Else
Debug.Print "Do Nothing"
End If
End Sub
The problem is that if the Qty in the subform is anything
but '0', the "CHANGE IT NOW" msg box pops up!
I'd appreciate ANY HELP!
Thanks,
Meilu