Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Function

Status
Not open for further replies.

Stargrove

Technical User
Feb 3, 2003
8
US
I need a Function that I can run from within a Query that will take a date from a table and spit out which half of the year (First or Second) it falls in. I am pretty new to functions, but here is what I have so far:

Function DateAnnual(AnnumDate As Variant) As String

Dim HALF As Variant
Dim WhichHalf As String

HALF = Format (AnnumDate, "mm")

If HALF <=6 Then
WhichHalf = "FIRST"
ElseIf HALF >6 Then
WhichHalf = "Second"
End If

End Function

In my query I create an expresstion field called with the following: ANNUM:DateAnnual([WO_Create_Date])

When I run the query nothing seems to get passed back to the query field (read blank). Any help would be appreciated.

James
 
Something like this in a stantard code module:
Public Function DateAnnual(AnnumDate As Variant) As String
If Not IsDate(AnnumDate) Then
DateAnnual = "?"
ElseIf Month(AnnumDate)<=6 Then
DateAnnual = "FIRST"
Else
DateAnnual = "Second"
End If
End Function

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top