AllExperts > Experts 
Search      

Using MS Access

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More Using MS Access Answers
Question Library

Ask a question about Using MS Access
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Scottgem
Expertise
I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience
I've been designing databases for over 15 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

 
   

You are here:  Experts > Computing/Technology > Business Software > Using MS Access > adding to fields in a query

Topic: Using MS Access



Expert: Scottgem
Date: 9/5/2008
Subject: adding to fields in a query

Question
Hi, thank you very much for taking the time to answering my question.

I would like to add two fields in a query and I want to place a / in between them.  But if the first or second or both fields is/are blank I don't want the / to be part of the query result. Also I don't want a space to be in front of the result if the first field is blank.

Answer
You can use an IIF to add the /. For example:

field1 & IIF(IsNull(field1) And IsNull(field2),"", IIF(Not IsNull(field1) AND Not IsNull(field2),"/",,"")

That should only show a slash if both are not null.

Hope this helps,
Scott<>
Microsoft Access MVP 2007
Author: MS Office Access 2007 VBA

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.