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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|