Hendra
You can run a public function from a query. Here is one example:
SELECT PatientName, fCalcAge([DateOfBirth])
FROM tbkPatientDemos
fCalcAge is a function that calculates the age given the date of birth.
Public Function fCalcAge(DOB As Variant)
'Purpose : Calculate age
'DateTime : 3/18/2000 10:50
On Error Resume Next
fCalcAge = DateDiff("yyyy", DOB, Now()) _
+ Int(Format(Now(), "mmdd") < Format(DOB, "mmdd"))
End Function
Calling it from a query would return all the patients and their current age.
Regards,
Bill
From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of
agesthahendra@ymail.com
Sent: Thursday, January 03, 2013 9:29 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Run VBA codes in query
Hi everyone,,, :)
Can we run vba codes in query..? for example i can run this codes below on click
button on a form, but is it possible to run the codes in query..? Here is the
codes sample:
If Month([TglSPT]) = 1 Then
Me.ExInt = "/SP/Set-DPRD/I/" & Year([TglSPT])
Me.NoSPPD_2 = "/SPPD/Set-DPRD/I/" & Year([TglSPT])
ElseIf Month([TglSPT]) = 2 Then
Me.ExInt = "/SP/Set-DPRD/II/" & Year([TglSPT])
Me.NoSPPD_2 = "/SPPD/Set-DPRD/II/" & Year([TglSPT])
Else Month([TglSPT]) = 3 Then
Me.ExInt = "/SP/Set-DPRD/III/" & Year([TglSPT])
Me.NoSPPD_2 = "/SPPD/Set-DPRD/III/" & Year([TglSPT])
Any explanation would be grateful,...thank you
Regards
Hendra Agestha
[Non-text portions of this message have been removed]
| Reply via web post | Reply to sender | Reply to group | Start a New Topic | Messages in this topic (2) |
Tidak ada komentar:
Posting Komentar