A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How to check whether the value in text field is Date type



 
 
Thread Tools Display Modes
  #1  
Old September 17th, 2009, 07:58 PM posted to microsoft.public.access.forms
Boon
external usenet poster
 
Posts: 115
Default How to check whether the value in text field is Date type

Hi,

I ahve a text box. How can I check if the value in the textbox is a date. I
want a user to only put in a date. I use the date selector (calendar). But
user can still type in text. I use Access 2007

Thanks,
Boon


  #2  
Old September 17th, 2009, 08:06 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default How to check whether the value in text field is Date type

"Boon" wrote in message
...
Hi,

I ahve a text box. How can I check if the value in the textbox is a date.
I want a user to only put in a date. I use the date selector (calendar).
But user can still type in text. I use Access 2007



If you set the Format property of the text box to one of the date formats
(e.g., "Short Date"), the user will only be able to enter values that can be
converted to dates. Or, if this is a bound control, if the underlying field
is a Date/Time field, the user won't be able to enter any non-date value.
Null values are still okay, in these cases.

The text box must be unformatted and unbound, you can use the IsDate()
function to determine whether the value can be interpreted as a date:

If IsDate(Me.txtDateEntered) Then
' This is a date value
Else
' It's null or a non-date.
End If

Note that all of these approaches allow the user to enter something like
"January 1", because Access can interpret that as a date.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:53 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.