If the field is empty, use a different field as a data source (1 Viewer)

frankt68

Registered User.
Local time
Today, 01:15
Joined
Mar 14, 2012
Messages
90
I wonder if this is possible?

I have a tale named tCBZ that serves as a data source for the form named fCBZ. The table has several fields, including the Short_Name and Long_Name fields. On the fCBZ form, only the Short_Name field is used(because it is shorter:)). However, for some records the field is blank. In this case, that is, when the Short_Name field is empty, I would like to use the Long_Name field as a data source.
So I'd like to do something like
if Short_Name is blank then show Long_name else show Short_Name


Is it possible and what do I have to do?
 

Minty

AWF VIP
Local time
Today, 00:15
Joined
Jul 26, 2013
Messages
10,366
You can use an IIf() in your underlying query for the form something like;

Code:
NonBlankName: IIf(Len(Short_Name & "") > 0, Short_Name, Long_Name)
 

isladogs

MVP / VIP
Local time
Today, 00:15
Joined
Jan 14, 2017
Messages
18,209
Or another similar IIf solution:

Code:
IIf(Nz([Short_Name],"")<>"",[Short_Name],[Long_Name])
 

frankt68

Registered User.
Local time
Today, 01:15
Joined
Mar 14, 2012
Messages
90
Thank you Minty and ridders, problem solved!:D
 

Users who are viewing this thread

Top Bottom