I have the following piece of code:
Dim Mpty As Boolean
Dim earliest As Date
Mpty = (IsNull(DMin("[NextCallDate]", "CallDate"))
If Mpty = False Then
If Me.NextCallDate.Value < DMin_("[NextCallDate]", "CallDate" And IsNull_(Me.NextCallDate.Value) = False Then
earliest = Me.NextCallDate
Else
earliest = DMin("[NextCallDate]", "CallDate"
End If
Forms!FrmSite!NextCallDateSite = earliest
Else
End If
This code is activated by the after update event of the control 'NextCallDate' on a form on the many side of a one-many relationship. What it is supposed to do is this -
1) It checks to see if there are any other values in the NextCallDate field.
2) If there are it compares the current value of the NextCallDate control on my form to these values.
3) It takes the lowest value that isn't a Null and puts it into the appropriate control on another, already open, form.
My problem is this:
If I have three records on the many side and I delete the lowest date value my code doesn’t alter the controls value on the one side to the next lowest value. However if I delete the value exit the form, go back to the empty date put something in and delete it straight away it DOES put the next lowest value in the appropriate control.
I’ve been staring at this bit of code for too long and it’s starting to drive me scatty.
Any help would be much appreciated.
Aexley
QFTD: “Fortune vomits on my eiderdown once again.” – Edmund Blackadder
Dim Mpty As Boolean
Dim earliest As Date
Mpty = (IsNull(DMin("[NextCallDate]", "CallDate"))
If Mpty = False Then
If Me.NextCallDate.Value < DMin_("[NextCallDate]", "CallDate" And IsNull_(Me.NextCallDate.Value) = False Then
earliest = Me.NextCallDate
Else
earliest = DMin("[NextCallDate]", "CallDate"
End If
Forms!FrmSite!NextCallDateSite = earliest
Else
End If
This code is activated by the after update event of the control 'NextCallDate' on a form on the many side of a one-many relationship. What it is supposed to do is this -
1) It checks to see if there are any other values in the NextCallDate field.
2) If there are it compares the current value of the NextCallDate control on my form to these values.
3) It takes the lowest value that isn't a Null and puts it into the appropriate control on another, already open, form.
My problem is this:
If I have three records on the many side and I delete the lowest date value my code doesn’t alter the controls value on the one side to the next lowest value. However if I delete the value exit the form, go back to the empty date put something in and delete it straight away it DOES put the next lowest value in the appropriate control.
I’ve been staring at this bit of code for too long and it’s starting to drive me scatty.
Any help would be much appreciated.
Aexley
QFTD: “Fortune vomits on my eiderdown once again.” – Edmund Blackadder