Hi Folks,
Due to a glitch I am working around, I need to create validation rules for certain fields in VBA versus using the validation rule property in the field property. For some reason, this code I am using below isn't working properly ... any ideas would be appreciated!
Private Sub Needs_Assessed_by_Instrument___Employment__Date_AfterUpdate()
If Me.Needs_Assessed_by_Instrument___Employment__Date < #1/1/2011# Or Me.Needs_Assessed_by_Instrument___Employment__Date > Now() Then
MsgBox ("Date too far in the past or in the future, data not saved, please correct!")
Me.Needs_Assessed_by_Instrument___Employment__Date = ""
End If
End Sub
Basically, no matter what date I put in the field, it triggers the message of the date being too far in the past or in the future. I am trying to analyze the date after the field has been updated so that any date OUTSIDE of the range of 1/1/2011 and Today the user gets a notice that the date is an error and has the opportunity to correct it. Once I can get this to work, after the message is displayed to the user IF the date is an error, I will erase that field so that the user must go back to fix it.
Due to a glitch I am working around, I need to create validation rules for certain fields in VBA versus using the validation rule property in the field property. For some reason, this code I am using below isn't working properly ... any ideas would be appreciated!
Private Sub Needs_Assessed_by_Instrument___Employment__Date_AfterUpdate()
If Me.Needs_Assessed_by_Instrument___Employment__Date < #1/1/2011# Or Me.Needs_Assessed_by_Instrument___Employment__Date > Now() Then
MsgBox ("Date too far in the past or in the future, data not saved, please correct!")
Me.Needs_Assessed_by_Instrument___Employment__Date = ""
End If
End Sub
Basically, no matter what date I put in the field, it triggers the message of the date being too far in the past or in the future. I am trying to analyze the date after the field has been updated so that any date OUTSIDE of the range of 1/1/2011 and Today the user gets a notice that the date is an error and has the opportunity to correct it. Once I can get this to work, after the message is displayed to the user IF the date is an error, I will erase that field so that the user must go back to fix it.