Hello everybody
I have a problem with a textbox bound to a date field and wonder, if somebody can help:
In my form, I have a textbox (txtDate) bound to the field ActionDate in tblActions. I would like to do the following:
- If the user enters a valid date, nothing happens (= the value is saved to the field)
- if the user enters an incomplete date, then complete it according to a rule, which I have specified in a function. If the rule can complete the date, it will do so and save the value, if not a user defined error messages appears and sends the user back to the textbox.
My idea was to check the textbox with the "BeforeUpdate" event and then to modify the content if needed. However, there are two problems:
- if the user enters an incomplete date (for example "01/") and then leaves the field (for example by pressing the tab-key) the MsAccess validation is executed first and creates a message ("The value you entered isn't valid for this field"). This prevents "BeforeUpdate" even to happen, so that I cannot complete the date.
- If the user enters a date, that is almost complete (for example 01/01/) then access automatically completes the date with the current year (--> 01/01/2017). This is again done before the "BeforeUpdate" so that I cannot avoid it. I have of course turned off the "autocomplete" property on the textbox but that seems not to help.
Is there any possibility to temporarily turn off the validation of Access related to the datatype of the field? Or do you have suggestions, how I could achieve what I want in a different way. I was also experimenting with "onDirty" or "onChange", the problem there is that the event is triggered starting from the first number entered in the field, which is not what I want.
Thanks in advance for your suggestions!
Stephan