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 » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Long date default for data entry to 2009



 
 
Thread Tools Display Modes
  #1  
Old February 4th, 2009, 01:16 AM posted to microsoft.public.access.gettingstarted
Pat Hughes
external usenet poster
 
Posts: 29
Default Long date default for data entry to 2009

I want to set the default for my table to be 2009 for my long date in the
entry form so that when the user enters the data they won't make a mistake
and enter 2008 or whatever. In fact they wouldn't even have to enter the
year. I just can't figure out how to put it in as the default. It seems
like it should be so easy. I don't want them to be able to change it.

Thanks
  #2  
Old February 4th, 2009, 01:50 AM posted to microsoft.public.access.gettingstarted
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Long date default for data entry to 2009

On Tue, 3 Feb 2009 17:16:01 -0800, Pat Hughes
wrote:

I want to set the default for my table to be 2009 for my long date in the
entry form so that when the user enters the data they won't make a mistake
and enter 2008 or whatever. In fact they wouldn't even have to enter the
year. I just can't figure out how to put it in as the default. It seems
like it should be so easy. I don't want them to be able to change it.

Thanks


Try entering 2/3 in a textbox bound to a date field. If you don't have an
input mask that disallows it, you'll get 02/03/2009. Users can explcitly type
a year, but if they don't it will be fine.

You can use code in the textbox's BeforeUpdate event to check if you wish:

Private Sub txtDatefield_BeforeUpdate(Cancel as Integer)
Dim iAns As Integer
If Not IsDate(Me!txtDatefield) Then
Cancel = True
MsgBox "Please enter a valid date", vbOKOnly
Else
If Year(DateValue(Me!txtDatefield)) Year(Date) Then
iAns = MsgBox("Do you really mean to enter a date in another year?", _
vbYesNo)
If iAns = vbNo Then
Cancel = True
End If
End If
End Sub

--

John W. Vinson [MVP]

  #3  
Old February 4th, 2009, 03:57 PM posted to microsoft.public.access.gettingstarted
Pat Hughes
external usenet poster
 
Posts: 29
Default Long date default for data entry to 2009

Thanks but I don't know code. I just thought that their might be an easier
solution in the default value or validation rule. I don't understand what
you are saying about "Try entering 2/3 in a textbox bound to a date field.
If you don't have an
input mask that disallows it, you'll get 02/03/2009. Users can explcitly type
a year, but if they don't it will be fine. " But anyway the field already has to be in the format of 02/03/2009. I just wanted to know if there is a way in the design of the table to make the default of the year to always be 2009 and where you can't change it.


THanks.

"John W. Vinson" wrote:

On Tue, 3 Feb 2009 17:16:01 -0800, Pat Hughes
wrote:

I want to set the default for my table to be 2009 for my long date in the
entry form so that when the user enters the data they won't make a mistake
and enter 2008 or whatever. In fact they wouldn't even have to enter the
year. I just can't figure out how to put it in as the default. It seems
like it should be so easy. I don't want them to be able to change it.

Thanks


Try entering 2/3 in a textbox bound to a date field. If you don't have an
input mask that disallows it, you'll get 02/03/2009. Users can explcitly type
a year, but if they don't it will be fine.

You can use code in the textbox's BeforeUpdate event to check if you wish:

Private Sub txtDatefield_BeforeUpdate(Cancel as Integer)
Dim iAns As Integer
If Not IsDate(Me!txtDatefield) Then
Cancel = True
MsgBox "Please enter a valid date", vbOKOnly
Else
If Year(DateValue(Me!txtDatefield)) Year(Date) Then
iAns = MsgBox("Do you really mean to enter a date in another year?", _
vbYesNo)
If iAns = vbNo Then
Cancel = True
End If
End If
End Sub

--

John W. Vinson [MVP]


  #4  
Old February 4th, 2009, 05:46 PM posted to microsoft.public.access.gettingstarted
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Long date default for data entry to 2009

On Wed, 4 Feb 2009 07:57:04 -0800, Pat Hughes
wrote:

Thanks but I don't know code. I just thought that their might be an easier
solution in the default value or validation rule. I don't understand what
you are saying about "Try entering 2/3 in a textbox bound to a date field.


If you type a date without typing the year, Access will automatically assume
the current year. Again... *try it*. Open a form (or a table datasheet for
that matter). Type

2/3

in a date/time field. See what gets inserted.
--

John W. Vinson [MVP]
  #5  
Old February 4th, 2009, 09:15 PM posted to microsoft.public.access.gettingstarted
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default Long date default for data entry to 2009

Actually, if the field is defined as Date/Time Datatype and the user only
enters a month and day, Accesss automatically adds the current year. Do this
help?

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via http://www.accessmonster.com

 




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:07 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.