Here's the code.
Hi there,
thanks for the reply, I close the form by clicking the close button. I added an event to the form that calls this sub when closing:
Private Sub MoveDataToWorkLog()
Dim curTotal As Currency
Dim strTotal As String
Dim ThisJobNumber As Long
Dim frm1 As Form
Dim ctl1 As Control
Dim TotalN As Integer
Dim PresentN As Integer
On Error GoTo errorhandler
Set frm1 = Forms("frmWorkItemsAndDetails")
Set ctl1 = frm1.Form.subfrmAllWorkItems
TotalN = ctl1.Form.Recordset.RecordCount
If TotalN = 0 Then
curTotal = 0
strTotal = " "
GoTo NoWorkEtcError
End If
ctl1.Form.Recordset.MoveFirst
PresentN = 1
curTotal = 0
strTotal = ""
Do Until PresentN = TotalN + 1
If Not IsNull(ctl1.Form.Recordset![ItemPrice]) And Not IsNull(ctl1.Form.Recordset![ItemQuantity]) And IsNumeric(ctl1.Form.Recordset![ItemPrice]) And IsNumeric(ctl1.Form.Recordset![ItemQuantity]) Then
curTotal = curTotal + (Round(ctl1.Form.Recordset![ItemPrice], 2) * Round(ctl1.Form.Recordset![ItemQuantity], 2))
End If
If Not IsNull(ctl1.Form.Recordset![ItemDescription]) And Not IsNull(ctl1.Form.Recordset![ItemQuantity]) And IsNumeric(ctl1.Form.Recordset![ItemQuantity]) Then
strTotal = strTotal & ctl1.Form.Recordset![ItemDescription] & " (" & ctl1.Form.Recordset![ItemQuantity] & "). "
End If
PresentN = PresentN + 1
ctl1.Form.Recordset.MoveNext
Loop
NoWorkEtcError:
Forms![frmWorkLog].Controls![PresentValueOfJob] = curTotal
Forms![frmWorkLog].Controls![Work Planned] = strTotal
Exit Sub
errorhandler:
MsgBox Err.Description
End Sub
Could the problem be with the form properties? any help much appreciated!
Thanks
Peter