A.D.TEJPAL
adtp at hotmail.com
Fri Jun 15 14:48:03 CDT 2007
Lembit, Prima-facie, it appears you need the birth dates mainly in the context of their recurrence aspect (anniversary etc) - where all that really matters is the date & month. Year is immaterial. One convenient alternative would be to use a single field (date type) with dynamic settings of input mask & date format as follows: (1) New record: (a) Input mask comes into force, having year 2000 pre-filled. The user need enter only the dd-mm part. Since it is a leap year, all possible valid combinations of dd-mm will be accepted (including 29-02). Of course, if complete information regarding year part is also available and the user so desires, the year part can be edited as needed. (b) No date format is required as the intention is for input mask to prevail. (2) Existing record: (a) No Input mask is applied. The intention is for date format to now prevail. (b) Date format dd-mm-yyyy comes into force. Sample code in form's module, as given below, should get you the desire behavior as outlined above. EDate is the name of control bound to the date field. Best wishes, A.D.Tejpal --------------- Code in form's module ================================ Private Sub EDate_AfterUpdate() Form_Current End Sub ----------------------------------------------------------- Private Sub EDate_Click() If Me.EDate > 0 Then Else Me.EDate.SelStart = 0 Me.EDate.SelLength = 0 End If End Sub ----------------------------------------------------------- Private Sub EDate_Enter() Me.EDate.SelStart = 0 Me.EDate.SelLength = 0 End Sub ----------------------------------------------------------- Private Sub Form_Current() If Me.EDate > #1/1/1900# Then ' Set Default Format Me.EDate.InputMask = "" Me.EDate.Format = "dd-mm-yyyy" Else ' Set Custom Mask With Preset Year 2000 Me.EDate.Format = "" Me.EDate.InputMask = "99-99-\2\0\0\0;0;_" End If If Me.NewRecord Then Me.EDate.SetFocus End If ' Me.NewRecord End Sub ================================ ----- Original Message ----- From: Lembit Soobik To: Access Developers discussion and problem solving Sent: Friday, June 15, 2007 19:33 Subject: [AccessD] Birthday in table Hi, everybody, I have tried to define a field in an A2003 table - in fact 2 fields - for birthday. thing is, in many cases I know only day and month, not the year. so I tried two fields: DD.MM as first and YYYY as second field. a) it wont let me enter a year, and I had to make it Integer instead. b) I can enter a day and month but it will add the year 2007 (behind the scenes) and therefore wont allow me to enter 29.02 now I can of course split it up into 3 fields: DD, MM, YYYY, but this would allow any error resultin in 41.21 as DD.MM so, how do you handle that? or do you allways have the full date including year? thanks for any help Lembit