Change IF Statement (1 Viewer)

Matizo

Registered User.
Local time
Today, 04:32
Joined
Oct 12, 2006
Messages
83
Hi,

Could someone please add to the IF Statement below one more field: BusinessName. Besically, if the Forename and Surname are NULL the BusinessName show appear and vice versa.

Code:
Client Name: IIf(IsNull([Surname]),IIf(IsNull([Forename]),[Forename]),IIf(IsNull([Forename]),[Surname],[Forename] & " " & [Surname]))


Thank you guys!
 

neileg

AWF VIP
Local time
Today, 12:32
Joined
Dec 4, 2002
Messages
5,975
How about
Code:
Client Name: IIf(IsNull([Surname]&[Forename]),[BusinessName]), [Forename] & " " & [Surname]))
 

Matizo

Registered User.
Local time
Today, 04:32
Joined
Oct 12, 2006
Messages
83
I get an error when I try to input this expression.
Error: "The expression you entered contains invalid syntax".


Thanks!
 

wilpeter

Canadian enthusiast
Local time
Today, 06:32
Joined
Nov 27, 2009
Messages
211
Looks like you didn't get a follow-up answer. Try this:
ClientName: IIf(IsNull([Surname]),IIf(IsNull([Forename]),[BusinessName],[Forename],IIf(IsNull([Forename]),[Surname],[Forename]&" "&[Surname]))
Sorry for the delay.
 

Matizo

Registered User.
Local time
Today, 04:32
Joined
Oct 12, 2006
Messages
83
Hi,

Thanks for the reply, but I'm still getting an error "wrong number of arguments".

Cheers
 

namliam

The Mailman - AWF VIP
Local time
Today, 13:32
Joined
Aug 11, 2003
Messages
11,695
Suspect neil was a bit to quick on the copy paste...
Two brackets to many...
Client Name: IIf(IsNull([Surname]&[Forename]),[BusinessName], [Forename] & " " & [Surname])
 

wilpeter

Canadian enthusiast
Local time
Today, 06:32
Joined
Nov 27, 2009
Messages
211
My apologies also. I left out the closing parenthesis before the second ISNULL or it would have worked. The only drawback with the shorter version, namliam, is that if there is only a surname, there'll be a blank space before it. Otherwise, it serves well.
 

Matizo

Registered User.
Local time
Today, 04:32
Joined
Oct 12, 2006
Messages
83
Thanks guys, it works now.

One more question, why is my delete query not working if I use the SQL below?

Code:
DELETE tblAllocations.*, ([tblAllocations_1].[EmployeeNo]=[tblAllocations].[EmployeeNo])
FROM tblAllocations, tblAllocations AS tblAllocations_1
WHERE (((([tblAllocations_1].[EmployeeNo]=[tblAllocations].[EmployeeNo]))=True));


THANKS!
 

neileg

AWF VIP
Local time
Today, 12:32
Joined
Dec 4, 2002
Messages
5,975
Suspect neil was a bit to quick on the copy paste...
Two brackets to many...
Client Name: IIf(IsNull([Surname]&[Forename]),[BusinessName], [Forename] & " " & [Surname])
Oops, too quick as you say namliam.
:eek:
 

neileg

AWF VIP
Local time
Today, 12:32
Joined
Dec 4, 2002
Messages
5,975
Thanks guys, it works now.

One more question, why is my delete query not working if I use the SQL below?

Code:
DELETE tblAllocations.*, ([tblAllocations_1].[EmployeeNo]=[tblAllocations].[EmployeeNo])
FROM tblAllocations, tblAllocations AS tblAllocations_1
WHERE (((([tblAllocations_1].[EmployeeNo]=[tblAllocations].[EmployeeNo]))=True));


THANKS!
Doesn't make sense to me. What are you trying to do?
 

Matizo

Registered User.
Local time
Today, 04:32
Joined
Oct 12, 2006
Messages
83
Basically I'm trying to delete double allocations. for example employee A cannot be allocated twice to the same job. Hence, I don't know how to prevent double allocations I'm trying to run the query to delete them when the occur...


Cheers!
 

namliam

The Mailman - AWF VIP
Local time
Today, 13:32
Joined
Aug 11, 2003
Messages
11,695
Lets start at the base, How would you find duplicates?
 

Users who are viewing this thread

Top Bottom