Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
FullName and CompanyName in One Field
Tim Elbert 
      
8 months ago
I would like to set up a field in a Query that gives the Company name, unless there isn't one associated, in which it will then put in the full name.  I am using this:
NameOrComp: IIf(([FullNameQ.CompanyName]=Null),[FullNameQ.FullName],[FullnameQ.CompanyName])

I am not doing something right.  I get the company name but not the full name in that field.
Debbie Heaney  @Reply  
     
8 months ago
I think you need to use string concatenation.

IIf(([FullNameQ.CompanyName]=Null),[FullNameQ.FullName],[FullnameQ.CompanyName])

would become

IIf(([FullNameQ.CompanyName]=Null),[FullNameQ.FullName] & ". " &[FullnameQ.CompanyName])

the ". " bit can be changed, or even removed, to suit your needs.

Richard Rost  @Reply  
          
8 months ago
Use IsNull.

IIF(IsNull(CompanyName), FullName, CompanyName)
Richard Rost  @Reply  
          
8 months ago
Debbie you're close but the IIF function requires three parameters, you've only got two. There, you're just concatenating full name and company name together if company name is null, but what to do if it's not null? You need that third argument.
Richard Rost  @Reply  
          
8 months ago
It's hard to remember when to use the IsNull function or when to check to see if something Is Null, but you almost never check to see if something equals null because nothing equals null. Null doesn't even equal null.
Richard Rost  @Reply  
          
8 months ago
You could also use the Nz function here:

S = Nz(CompanyName, FullName)

This basically says "if CompanyName Is Null then set S equal to FullName, otherwise set it equal to CompanyName."
Tim Elbert OP  @Reply  
      
8 months ago
Thank you all.  I will have to research the Nz function and learn more.
Richard Rost  @Reply  
          
8 months ago
The first solution might be easier to understand at this stage. But that's why you're here: to learn! :)

And you made it into this Friday's Quick Queries video.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/7/2026 10:33:30 AM. PLT: 1s