Function returning expression.

btothap

jr. member, sr. lurker
Local time
Today, 02:22
Joined
May 9, 2003
Messages
20
Howdy. I'm trying to set date criteria in a query based on the day of the week. On wed-fri I only need one date value in the criteria, which works fine. On tuesdays, however I need the previous thursday and friday to be criteria. I'm currently calling a function in the criteria box on the query grid.
Here's that function..

Public Function dayselect()
Dim crun
crun = Format(Now(), "ddd")

If crun = "Tue" Then
dayselect = ((date - 5) Or (date - 4))
Else
dayselect = [Forms]![manageSales]![StartDate]
End If

End Function

StartDate is set with the onClick event that launches the query.
How can I modify the syntax of the function so that the criteria returned for tuesday is date1 OR date2.

Thanks so much.

-shane.
 
for one change your dim to Dim crun as string

then try this

If crun = "Tue" Then
dayselect = "#" & format((date - 5),"mm/dd/yyyy") & "# Or #" & format((date - 4),"mm/dd/yyyy") & "#"
Else
dayselect = [Forms]![manageSales]![StartDate]
End If
 
Thanks for your help,

Unfortunately I'm still getting a "This expression is typed incorrectly or is to complex to be evaluated..." error message when I run the query.

I'll keep playin with it.

-shane.
 

Users who are viewing this thread

Back
Top Bottom