Help folks,

I have problem in writing a code which will reference a calculated control in the sub-form.


Private Sub fsubKpPmtVou_Exit(Cancel As Integer)
If me.fsubKpPmtVou![Total]<> me.[Amt-Cr] Then
Sound 3
me.[Amt-Cr].SetFocus
End If
End Sub


Private Sub fsubKpPmtVou_Enter()
me.fsubKpPmtVou.Form.Requery
End Sub


Private Sub Form_Close()
Dim db As Database, rct As Recordset, vn As String
If me.fsubKpPmtVou![Total]<> me.[Amt-Cr] Then
vn = me.VouNo
Set db = CurrentDb
Set rct = db.OpenRecordset("qryKpPmtVou")
rct FindFirst "VouNo=vn"
If Not rct.NoMatch Then
rct.Delete
End If
End If
End Sub

([Total] is an unbound control capturing the sum of a bound control "[Amt-Dr]" in the sub-form.)

The "fsubKpPmtVou_Exit" works fine while the "Form_Close" event halts at the "If me.fsubKpPmtVou![Total]......." line.

Any thing has gone wrong or I really cannot reference a calculated control in the form or sub-form all together. Your expertise is appreciated.