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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

syntax error on =IIf statement

Status
Not open for further replies.

evansc

Technical User
Jul 19, 2004
42
US
The following two syntaxes work perfectly:

=IIf([End Date] Is Null,Format$([Start Date],"mmmm dd"", ""yyyy"),Format$([Start Date],"mmmm dd"", ""yyyy") & " to " & Format$([End Date],"mmmm dd"", ""yyyy"))

=Trim("Thank you for agreeing to be a faculty member for the " & [Activity Title] & " course for " & [Invitees] & " to be held on " & Format$([Start Date],"mmmm dd") & " to " & Format$([End Date],"mmmm dd") & " at the " & [Location] & ".")


I put the concepts together in the following--but I keep getting a syntax error. It says "You may have entered an operand without an operator." Did I miss an & somewhere?

=IIf ([End Date] Is Null,"Thank you for agreeing to be a faculty member for the " & [Activity Title] & " course for " & [Invitees] & " to be held on " & Format$([Start Date],"mmmm dd") & " at the " & [Location] & ".", "Thank you for agreeing to be a faculty member for the " & [Activity Title] & " course for " & [Invitees] & " to be held on " & Format$([Start Date],"mmmm dd") & “ to "& Format$([End Date],"mmmm dd")& " at the " & [Location] & ".")

Thank you for any help!
 
Evan:

I believe that you are limited to 255 characters in an IIF expression. (Access help does not specifically mention this but it does indicate that 255 is the limit for parameters in a parameter query.)

You may need to create a custom function to handle this.

HTH

Larry De Laruelle

 
I used them in a messagebox and was able to run it by changing

[End Date] Is Null

to

IsNull([End Date])

PaulF
 
I tried that before I posted--I got the same error. Would the version be an issue? I have 2002.
 
only other thing I had to change was

“ to "& Format$([End Date],"mmmm dd")& " at the " & [Location] & ".")

To

" to "& Format$([End Date],"mmmm dd")& " at the " & [Location] & ".")

the left double quote wasn't correct.

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top