My pleasure, Hendra.
Bill
--- In MS_Access_Professionals@yahoogroups.com, Agestha Hendra wrote:
>
> Thank you Bill,...more usefull knowledge for me ... :)
>
> Regards
> Hendra
>
>
>
> ________________________________
> Dari: Bill Mosca
> Kepada: MS_Access_Professionals@yahoogroups.com
> Dikirim: Jumat, 4 Januari 2013 0:42
> Judul: RE: [MS_AccessPros] Run VBA codes in query
>
>
> Â
> 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@...
> 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]
>
>
>
>
> [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 (6) |
Tidak ada komentar:
Posting Komentar