Re: disable field

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



To calculate the age in years and weeks, calculate the difference in weeks.
The years will be the integer portion of the total weeks divided by 52, the
weeks will be total weeks mod 52:

However, now that I'm looking closer at your original code, I'm getting
confused. In one case it used Me.txtBirthDate, in another it used [DOBPET].
I'll assume that you have a field on your form named txtBirthDate which is
bound to the DOB field in your table. With that assumption, you need
something like:

Private Sub txtBirthDate_AfterUpdate()

If IsDate(Me.txtBirthDate) Then
If DateDiff("ww", Me.txtBirthDate, Date) < 8 Then
Me.txtAge = "Invalid Age"
ElseIf DateDiff("yyyy", Me.txtBirthDate, Date) > 8 Then
Me.txtAge = "Invalid Age"
Else
Me.txtAge = DateDiff("ww", Me.txtBirthDate, Date) \ 52 & _
" years, " & _
DateDiff("ww", Me.txtBirthDate, Date) Mod 52 & _
" weeks."
End If
Else
Me.txtAge = "Invalid Date of Birth"
End If

End Sub

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"Gerald" <Gerald@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CF84A6F9-DEF5-47FA-8D64-80E1051B6EAF@xxxxxxxxxxxxxxxx
> Cheers, Douglas for ur suggestion..
>
> Now, this is where I stand
>
> DOB = date of birth in date format
> age = populates age in years and weeks (as entered in DOB)
>
> if age above 8 years 0 weeks age field should display " invalid age "
> if age below 8 weeks age field should display " invalid age "
>
> can u possibly advice how best can we do this ?
>
> Any help will be appreciated
>
> Many thanks
>
>


.



Relevant Pages

  • Re: Id like NOT to see something on my form.
    ... For those whose year of birth I know, ... The union query mentioned below was developed in order to combine DOB & DOA ... have a second field which calculates age. ... Add an unbound control to your form. ...
    (microsoft.public.access.forms)
  • Re: A date function in Access using VB
    ... Dim currentSeason As Date ... ' put the age on the form ... Doug Steele, Microsoft Access MVP ... DOB and the playingAge are bound to a database. ...
    (microsoft.public.access.formscoding)
  • Re: index card
    ... My excel spreadsheet is the equivalent of index cards - I list each person - ... their parents, spouse, occupation, dob, dom, dod, locations for each and age ...
    (soc.genealogy.britain)
  • Re: Need to map records from one schema to a similar one in sequence
    ... having sequence nodes with records in them, but when one is mapped to ... Schema One ... <DOB> ...
    (microsoft.public.biztalk.general)
  • Re: datediff
    ... For an expression in a Control Source to work, ... But when the DOB field is blank, ... Do you want the person's age at the time the record is ... Answers/posts based on Access 2000 ...
    (microsoft.public.access.gettingstarted)