Birthday format

endri81

Registered User.
Local time
Yesterday, 18:00
Joined
Jul 5, 2010
Messages
121
I have a birthday textbox datatype number.Is it possible in this box for the user to enter both formats number like 30 or 13/01/1981 and the age to be converted in number?

Please help
Regards
 
How are you going to store the birthday in the field in the table mores the question?

Also if I type in 30 how is it going to know my DOB?
 
You are totally right I didn't explained well myself.
In the table age will be saved as number in our case 30 because for us is important the age and not the birthday.But as long as in the papers sometimes is written the age and sometimes the birthday I want the age to be calculated automatically in order to facilitate the user.
Regards
 
What you need to do in that case is to let the user type in a DOB and if the after update recogonises the entry a being a valid date (If IsDate(....) Then) then convert the DOB entered into an age using the DateDiff() function.
 
Can you help me please with some code because I am an Access newbie: (
 
you would have to use an unbound field, and have a REAL (HIDDEN) date field.

then using the unbound field

a) test if date, and assign the date to the real date field

b) test if number, and then use this as age, and maybe calculate a date of 1st Jan whatever year (not exactly accurate, but OK)

c) anything else - reject input.
 
sorry, i'm actually busy, and haven't got the time to sort out code.

I did explain how a method of how I might do it, personally, and you should be able to follow that, or you could come up with another way of achieving what you want.
 
if IsDate(DateFiled) then
AgeField = DateDiff("yyyy", Now(), DateField)
end if


one note:
dateDiff("yyyy", #31/12/2010#, #1/1/2011#)= 1
 
Like gemma-the-husky mentioned:
Code:
If IsDate([field]) Then
    ... DateDiff() here ...
ElseIf IsNumeric([field]) Then
    ... set age value here ...
End If
 

Users who are viewing this thread

Back
Top Bottom