Latest Date

  • Thread starter Thread starter Ang
  • Start date Start date
A

Ang

Hi ,

I check Access 2002 and it works but not Access 97. I am making it work on
Access 97. I have main form with two subforms. I am not too sure if I did
wrong on the code. I will be appreciated your feedback. Thanks....

Main Form : txtstatus

SubForm#1: txtDate3

SubForm#2 : txtDate4
txtDate5
******************************
Private Sub Form_Load()
txtStatus = "No dates yet"
End Sub

Private Sub txtDate3_AfterUpdate()
If txtDate3 > Nz(txtDate4) And txtDate3 > Nz(txtDate5) Then
txtStatus = txtDate3
Else
MsgBox "This is not the latest date"
End If
End Sub

Private Sub txtDate4_AfterUpdate()
If txtDate4 > Nz(txtDate3) And txtDate4 > Nz(txtDate5) Then
txtStatus = txtDate4
Else
MsgBox "This is not the latest date"
End If
End Sub

Private Sub txtDate5_AfterUpdate()
If txtDate5 > Nz(txtDate3) and txtDate5 > Nz(txtDate4) Then
txtStatus = txtDate5
Else
MsgBox "This is not the latest date"
End If
End Sub
*********************************
 
Maybe you need to go ahead and put in the zero (0) as the second argument of
the NZ function, cause if the function thinks the textbox should be a
string, not a number, then it will return zero-length string, which is not
what you want. The other thing you may also need to consider, you need to
be sure it's reading the information in the textboxes as dates. Off97
doesn't seem to pick up on the proper format of the information as well as
later versions of Office, thus could be one of the reasons why you are
running into this issue in 97, but not in later versions. Due to various
issues that I have ran into in MS Office, I have learned not to leave
anything vague open for the possibility of incorrect interpretation by the
programming language.

Granted, there's 2 sides, you want to have your code as dynamic as possible,
meaning not have your data in static mode unless it needs to be for
historical purposes, but then on the other side, you also need to have tight
controls in place so as you don't run into issues like this so readily.
 
Back
Top