Re: disable field
- From: "Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx>
- Date: Sat, 20 Aug 2005 09:34:03 -0400
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
>
>
.
- Follow-Ups:
- Re: disable field
- From: Gerald
- Re: disable field
- References:
- disable field
- From: Gerald
- Re: disable field
- From: Arvin Meyer [MVP]
- Re: disable field
- From: Gerald
- Re: disable field
- From: Arvin Meyer
- Re: disable field
- From: Gerald
- Re: disable field
- From: Douglas J. Steele
- Re: disable field
- From: Gerald
- disable field
- Prev by Date: Re: control to null
- Next by Date: Re: Up down arrow keys only work on list box after a mouse click...
- Previous by thread: Re: disable field
- Next by thread: Re: disable field
- Index(es):
Relevant Pages
|