Private Sub MOS_Comp_Date()
If IsNull([MOS Grad Dt]) Then
[MOS Comp Dt] = [MOS Grad Dt]
Elseif IsNull([MOS Grad Dt 2]) Then
[MOS Comp Dt] = [MOS Grad Dt]
Elseif IsNul(l[MOS Grad Dt 3]) Then
[MOS Comp Dt] = [MOS Grad Dt 2]
Elseif IsNull([MOS Grad Dt 4]) Then
[MOS Comp Dt] = [MOS Grad Dt 3]
Else
[MOS Comp Dt] = [MOS Grad Dt 4]
End If
End Sub
No error messages, but the result is all blanks?
What are the values in MOS Grad Dt, Dt 2, Dt 3 and Dt 4? What result do you
expect? What event calls this Sub?
I actually worked through this problem several times. Sometimes there is
only one school to go to and I need the beginning and end dates for that
school. Other times there are four different schools and I need the
beginning and end dates of all four.
Then you have a One (student?? whatever this table models) to Many (schools)
relationship. "Fields are expensive, records are cheap" - someday you might
have *FIVE* schools and completely break your data model!!
These Grad Dt values should be in separete *records* of another table related
one to many to this table. Doing so will let you use a very simple Max
expression in a Totals query to find the last date.
If you really want the last non-Null value in the four fields, AND can
reliably and certainly count on there never being a NULL out of order, try
Private Sub MOS_Comp_Date()
[MOS Comp Dt] = NZ([MOS Grad Dt 4], NZ([MOS Grad Dt 3], NZ([MOS Grad Dt 2], _
NZ([MOS Grad Dt]))))
End Sub
This also assumes that Grad Dt 4 is always later than Grad Dt 3, and so on,
which might not be the case.
For this particular report I need the
ultimate end date, whether only one school is involved or all four are
involved. For historical data pruposes, I must maintain the information for
all four schools so I cannot simply eliminate the first through third. So it
appears that I have redundant data but each field represents a different
school and I cannot overwrite the old with the new.
All help is GREATLY appreciated.
BTW - I am using Access 2000 if that makes a difference - NOT my choice -
government is too cheap to front for anything updated.
Nothing wrong with 2000 so long as you have applied all the service packs. It
sort of oinked when first released but it's pretty reliable now. Nothing in
the later versions will affect this particular problem.
John W. Vinson [MVP]