G
graeme34 via AccessMonster.com
Hi
Could anybody tell me how to refer to a control on a child form in the
master forms on close event?
I have the following code which updates underlying tables when the confirm
despatch entry form closes.
Private Sub Form_Close()
' On closing the confirm despatch form delete any records
' from the despatch line table that are = 0
' i.e. not goods sent this delivery and prevent repetitive
' records of 0 delivery
Dim rsDes As DAO.Recordset
Dim rsSal As DAO.Recordset
Dim strSQL As String
Dim lngDesNum As Long
strSQL = "SELECT tblDespatch.DespatchConfirmed ,tblDespatch." _
& "OrderComplete, tblDespatchLine.* " _
& " FROM tblDespatch INNER JOIN tblDespatchLine " _
& " ON tblDespatch.DespatchNumber = tblDespatchLine." _
& "[Despatch Number] WHERE tblDespatch.SalesOrderNumber = " _
& Me.SalesOrderNumber & " ORDER BY [Despatch Number] DESC;"
Set rsDes = CurrentDb.OpenRecordset(strSQL)
Set rsSal = CurrentDb.OpenRecordset("qryOutstandingSales", _
dbOpenDynaset)
lngDesNum = rsDes![Despatch Number]
If rsDes!DespatchConFirmed = False Then Exit Sub
Do While rsDes!SalesOrderNumber = Me!SalesOrderNumber And _
rsDes![Despatch Number] = lngDesNum
If rsDes![Quantity Sent] = 0 Then
rsSal.FindFirst "SalesOrderNumber = " _
& Me!SalesOrderNumber
Do While rsSal!SalesOrderNumber = Me!SalesOrderNumber
If rsSal![Product Code] = rsDes![Product Code] _
Then
rsSal!DespatchNotePrinted = False
Exit Do
End If
rsSal.MoveNext
Loop
rsDes.Edit
rsDes!OrderComplete = False
rsDes.Update
rsDes.Delete
End If
If rsDes![Quantity Sent] < Me.subfrmConfirmDespatch!txtOutstanding
Then
rsDes.Edit
rsDes!OrderComplete = False
rsDes.Update
End If
rsDes.MoveNext
If rsDes.EOF = True Then Exit Sub
Loop
End Sub
The problem seems to be Me.subfrmConfirmDespatch!txtOutstanding as this is
having a NULL value when debugging.
Any help would be greatly appreciated....
Could anybody tell me how to refer to a control on a child form in the
master forms on close event?
I have the following code which updates underlying tables when the confirm
despatch entry form closes.
Private Sub Form_Close()
' On closing the confirm despatch form delete any records
' from the despatch line table that are = 0
' i.e. not goods sent this delivery and prevent repetitive
' records of 0 delivery
Dim rsDes As DAO.Recordset
Dim rsSal As DAO.Recordset
Dim strSQL As String
Dim lngDesNum As Long
strSQL = "SELECT tblDespatch.DespatchConfirmed ,tblDespatch." _
& "OrderComplete, tblDespatchLine.* " _
& " FROM tblDespatch INNER JOIN tblDespatchLine " _
& " ON tblDespatch.DespatchNumber = tblDespatchLine." _
& "[Despatch Number] WHERE tblDespatch.SalesOrderNumber = " _
& Me.SalesOrderNumber & " ORDER BY [Despatch Number] DESC;"
Set rsDes = CurrentDb.OpenRecordset(strSQL)
Set rsSal = CurrentDb.OpenRecordset("qryOutstandingSales", _
dbOpenDynaset)
lngDesNum = rsDes![Despatch Number]
If rsDes!DespatchConFirmed = False Then Exit Sub
Do While rsDes!SalesOrderNumber = Me!SalesOrderNumber And _
rsDes![Despatch Number] = lngDesNum
If rsDes![Quantity Sent] = 0 Then
rsSal.FindFirst "SalesOrderNumber = " _
& Me!SalesOrderNumber
Do While rsSal!SalesOrderNumber = Me!SalesOrderNumber
If rsSal![Product Code] = rsDes![Product Code] _
Then
rsSal!DespatchNotePrinted = False
Exit Do
End If
rsSal.MoveNext
Loop
rsDes.Edit
rsDes!OrderComplete = False
rsDes.Update
rsDes.Delete
End If
If rsDes![Quantity Sent] < Me.subfrmConfirmDespatch!txtOutstanding
Then
rsDes.Edit
rsDes!OrderComplete = False
rsDes.Update
End If
rsDes.MoveNext
If rsDes.EOF = True Then Exit Sub
Loop
End Sub
The problem seems to be Me.subfrmConfirmDespatch!txtOutstanding as this is
having a NULL value when debugging.
Any help would be greatly appreciated....