Clears SOME fields when new date entered

Ads

Registered User.
Local time
Today, 10:40
Joined
Jan 16, 2014
Messages
12
Hello

I have a form that has bound fields.
I would like some fields to clear when I enter a new date into a date field with an old date.
I do want the new date to replace the old date and I do want to delete the other info in the fields that I want to clear...

Can this be done?

Thanks!
 
Typically I would not recommend you ever destroy information, which is what you are proposing. You are saying you want to overwrite a particular date, and on that action you want a handful of other fields erased, but why not keep that previous data? Why destroy it?
Curious,
Mark
 
Normally I would agree with you. In this case, we are removing annually changing info that confuses another department if they see it.

When a job is being delivered, we email the client to tell them it shipped, then we go in and remove last years followup info and it never fails that someone misses deleting something which just causes issues.

I thought if we could just have the info removed when the new date is entered I wouldn't have to worry about people doing things correctly!
 
You can handle the AfterUpdate event of the date's Textbox control, and in that event handler, you can set the values of the other controls.
Code:
Private Sub YourDateControl_AfterUpdate()
[COLOR="Green"]'  keep in mind, as far as best practices go, this is an ugly hack[/COLOR]
   Me.OtherControl1 = Null
   Me.OtherControl2 = Null
   Me.OtherControl3 = Null
End Sub
Is that enough information? Using this technique, however, even if you edit that date field for purposes other than the one you state, the code will run and destroy that other data. Maybe it is worth validating that the date change exceeds 10 months or something, or add a confirmation MsgBox(), but this is the problem with automating the destruction of data: you get less value with more complexity.

Always a better solution is to add new row to a related table which stores the latest status, date, event, or whatever the time-sensitive piece is. Then, only show that latest record as the current one.

hth
Mark
 
Thanks Mark, I will give that a try!
 

Users who are viewing this thread

Back
Top Bottom