# MS Access Form: Checking for a valid date in an unbound text box

**URL:** <https://boards.straightdope.com/t/ms-access-form-checking-for-a-valid-date-in-an-unbound-text-box/345316>\
**Category:** Factual Questions\
**Created:** [February 20, 2006, 2:52pm UTC](https://boards.straightdope.com/t/ms-access-form-checking-for-a-valid-date-in-an-unbound-text-box/345316 "2006-02-20T14:52:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/zoid/32/336_2.png) [@zoid](https://boards.straightdope.com/u/zoid)\
**Post date:** [February 20, 2006, 2:52pm UTC](https://boards.straightdope.com/t/ms-access-form-checking-for-a-valid-date-in-an-unbound-text-box/345316/1 "2006-02-20T14:52:00Z")

</div>

Given that there are number of valid date formats in MS Access, how can I check an unbound text box to see if the user has entered a valid date?

---

<div class="post-metadata">

**Author:** ![Left\_Hand\_of\_Dorkness](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/left_hand_of_dorkness/32/7156_2.png) [@Left\_Hand\_of\_Dorkness](https://boards.straightdope.com/u/Left_Hand_of_Dorkness)\
**Post date:** [February 20, 2006, 5:46pm UTC](https://boards.straightdope.com/t/ms-access-form-checking-for-a-valid-date-in-an-unbound-text-box/345316/2 "2006-02-20T17:46:29Z")

</div>

> [@zoid](#):
>
> Given that there are number of valid date formats in MS Access, how can I check an unbound text box to see if the user has entered a valid date?

This isn’t exactly what you’re asking, I think, but it might solve the problem. Under the text box data properties, under input mask, you can get a wizard that allows you to force a certain format, e.g., 99/99/0000;0;\_ (for a long date). In this format, they’ve got to use a four-digit year, but at least it won’t accept anything else. Will this solve your problem?

Daniel

---

<div class="post-metadata">

**Author:** ![redtail23](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@redtail23](https://boards.straightdope.com/u/redtail23)\
**Post date:** [February 20, 2006, 6:10pm UTC](https://boards.straightdope.com/t/ms-access-form-checking-for-a-valid-date-in-an-unbound-text-box/345316/3 "2006-02-20T18:10:50Z")

</div>

Alternatively, there’s an IsDate function that you could add to the LostFocus event for that field. IsDate(datevalue) will return True if it’s a recognizable date and False if not. However, you would need to do some coding around that function to force them to redo the date as needed.

---

<div class="post-metadata">

**Author:** ![zoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/zoid/32/336_2.png) [@zoid](https://boards.straightdope.com/u/zoid)\
**Post date:** [February 20, 2006, 6:11pm UTC](https://boards.straightdope.com/t/ms-access-form-checking-for-a-valid-date-in-an-unbound-text-box/345316/4 "2006-02-20T18:11:26Z")

</div>

> [@Left Hand of Dorkness](#):
>
> This isn’t exactly what you’re asking, I think, but it might solve the problem. Under the text box data properties, under input mask, you can get a wizard that allows you to force a certain format, e.g., 99/99/0000;0;\_ (for a long date). In this format, they’ve got to use a four-digit year, but at least it won’t accept anything else. Will this solve your problem?
> 
> Daniel

I’m not sure, I’ll play around with it and see how it behaves.

Thanks for the tip!

---

<div class="post-metadata">

**Author:** ![zoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/zoid/32/336_2.png) [@zoid](https://boards.straightdope.com/u/zoid)\
**Post date:** [February 20, 2006, 7:01pm UTC](https://boards.straightdope.com/t/ms-access-form-checking-for-a-valid-date-in-an-unbound-text-box/345316/5 "2006-02-20T19:01:23Z")

</div>

> [@redtail23](#):
>
> Alternatively, there’s an IsDate function that you could add to the LostFocus event for that field. IsDate(datevalue) will return True if it’s a recognizable date and False if not. However, you would need to do some coding around that function to force them to redo the date as needed.

That may be exactly what I need!
