Date validation teaser!!!

adambc

Active Member
Joined
Jan 13, 2020
Messages
412
Office Version
  1. 365
Platform
  1. Windows
I have a Workbook which records requests received, which is periodically updated with progress - NB it is not used in lieu of Project Management/Project Tracking tools; it is there to provide the Executive Team in the charity I’m volunteering at (in retirement!) an oversight …

It works using two UserForms …

frmNewRequest … used to add new requests - there are a number of Command Button/Text Box combinations where the Command Button calls a Date Picker and writes the date selected to the Text Box - behind this I have written a simple VBA date validation routine that is triggered by a Text Box Change to ensure that the date selected is not before today

frmUpdateRequest … is essentially the same form except that it loads the data into the form from the underlying Worksheet record - I still need the aforementioned Command Button/Text Box combinations including the validation, but the problem occurs when a date previously entered has now past - when the form loads the data (into the Text Box), the validation kicks in, which I don’t want to happen to allow reporting on dates “missed”

Can anyone help eg is there a way I can distinguish between a Text Box Change as a result of the Command Button/Date Picker, from a Text Box Change as a result of loading an existing record?

Thanks for any help you can give me …
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Don't use the Change event? Not sure what would be more suitable for your use re date validation but I suspect BeforeUpdate. Consider doubleclick event on date fields and eliminate the buttons?
 
Upvote 0
Don't use the Change event? Not sure what would be more suitable for your use re date validation but I suspect BeforeUpdate. Consider doubleclick event on date fields and eliminate the buttons?
@Micron

How will BeforeUpdate help? Surely the validation will still trap updates as a result of loading data rather than “manual” input?

And how would a doubleclick event vs. a Command Button help?
 
Upvote 0
I have a Workbook which records requests received, which is periodically updated with progress - NB it is not used in lieu of Project Management/Project Tracking tools; it is there to provide the Executive Team in the charity I’m volunteering at (in retirement!) an oversight …

It works using two UserForms …

frmNewRequest … used to add new requests - there are a number of Command Button/Text Box combinations where the Command Button calls a Date Picker and writes the date selected to the Text Box - behind this I have written a simple VBA date validation routine that is triggered by a Text Box Change to ensure that the date selected is not before today

frmUpdateRequest … is essentially the same form except that it loads the data into the form from the underlying Worksheet record - I still need the aforementioned Command Button/Text Box combinations including the validation, but the problem occurs when a date previously entered has now past - when the form loads the data (into the Text Box), the validation kicks in, which I don’t want to happen to allow reporting on dates “missed”

Can anyone help eg is there a way I can distinguish between a Text Box Change as a result of the Command Button/Date Picker, from a Text Box Change as a result of loading an existing record?

Thanks for any help you can give me …
I have solved the teaser myself!!!

I’ve put the validation in the Command Button sub before the date selected gets anywhere near the Text Box - as a result, when I load a date in the past into the Text Box no validation takes place …

Simple when you think about it!!!
 
Upvote 0
Solution
How will BeforeUpdate help? Surely the validation will still trap updates as a result of loading data rather than “manual” input?
If data doesn't pass validation, you cancel the event - no update, but that's about validation. Your problem was that the change event was being triggered by the userform initialization event, yes? You solved your problem the same way - you just moved validation to a button click event. Usually, validation is done before the data is accepted in the control, not after.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,185
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top