how to filter data

D

datin

Hi,
currently Im developing a database for HR.I need to display only child that
will attend public examination in my report.Pls help me to solve this problem.

Private Sub DOB_AfterUpdate()
Dim age1 As String
Me!Age = DateDiff("yyyy", DOB, Date) + Int(Format(DOB, "ddmm") >
Format(Date, "ddmm"))
Refresh
If Me!Age = 15 Then
Me!Exam = "PMR"
Else
If Me!Age = 17 Then
Me!Exam = "SPM"
Else
If Me!Age = 12 Then
Me!Exam = "UPSR"
Else
If Me!Age = 19 Then
Me!Exam = "STPM"
Else
Me!Exam = ""
End If
End If
End If
End If
End Sub


thank you and regards
 
A

Access101

I like MGFoster's DateSerial solution, and here's some additions in my style
of coding:
Private Sub DOB_AfterUpdate()

'Me!Exam should show as UPSR in this example

Dim intExam(20) As String, birthdatefield As Date, age As Integer

intExam(12) = "UPSR"
intExam(15) = "PMR"
intExam(17) = "SPM"
intExam(19) = "STPM"

birthdatefield = #11/17/1995#

age = Year(Now()) - Year(birthdatefield) + (DateSerial(Year(Now()),
Month(birthdatefield), Day(birthdatefield)) > Now())

Me!Exam = intExam(age)

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top