The following should do the trick also, without using vba:
=IIf(
[txt_coursedate]>DMax("certexpires","qry_personcert"),
DateAdd("m",36,[txt_coursedate]),
IIf([txt_coursedate]>=DateAdd("m",-3,DMax("certexpires","qry_personcert")),
DateAdd("m",36,DMax("certexpires","qry_personcert"))...