IIf syntax to select one field or another

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to create a query for my library database that will return
[Organizations]![Abbrev] when [Authors]![AuthurNum] is null and otherwise
return [Authors]![FirstName] & " " & [Authors]![LastName]. I've tried every
combination with parentheses and commas and spaces, but I keep getting error
messages in the query grid; or when I go to the table view, I get #Error.
How can I fix this?

By:
IIf(IsNull[Books]![AuthorID],[Organizations]![Abbrev],[Authors]![FirstName] &
" " & [Authors]![LastName])
 
Only the actual field needs to be in the IsNull function. To make it obvious
what's missing, I've put spaces around the parentheses I added.

IIf(IsNull ( [Books]![AuthorID] )
,[Organizations]![Abbrev],[Authors]![FirstName] & " " &
[Authors]![LastName])
 
You're missing brackets around you IsNull function call. It should be:

IIf(IsNull([Books]![AuthorID]),[Organizations]![Abbrev],[Authors]![FirstName] &
" " & [Authors]![LastName])

HTH,
Barry
 
Back
Top