Results 1 to 4 of 4
  1. #1
    accessLearn is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jul 2015
    Posts
    11

    How to hide comma if there is no value

    I have an ms access report where I have an invisible combo box that gets the value for the employee name and role from the query which selects data from tblemployee.

    I am using this box to display name and role in the text box for report using the following code
    =Combo58.Column(1) & ", " & Combo58.Column(2) in the control source property.
    The issue is that if there an employee name and role, then it looks fine but If there is no nameand role then it display “,” in the report.

    I want to display “,” only when I have data in the combo box for employee name and role, I tried using Nz function but it is not working.
    I would appreciate any suggestion.

    Thank you,


    Blyzzard

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,735
    You could try (UNTESTED)

    =IIf ( len(me.Combo58.Column(1))> 0 And len(me.Combo58.Column(2)) >0, Combo58.Column(1) & ", " & Combo58.Column(2), "")

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,953
    So what did you use Nz() on - the combobox or the column references?

    Any expression involving math operators and Null will return Null. The + is a very special operation character. It not only does number addition but also concatenates. So if you '+' text data and any field is Null, the expression will return Null. In some cases using + instead of & can deal with what you are encountering.

    Problem is, combobox list columns are always text which means an empty string instead of Null if there is no data. Try an IIf()

    IIf([Combo58] Is Null, Null, Combo58.Column(1) & ", " & Combo58.Column(2))
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    accessLearn is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jul 2015
    Posts
    11
    Thank you. It worked!!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Comma in filename?
    By lithium in forum Programming
    Replies: 4
    Last Post: 10-23-2014, 01:34 PM
  2. comma-separate for fee
    By msasan1367 in forum Access
    Replies: 1
    Last Post: 05-29-2013, 08:16 PM
  3. comma in a query
    By jscriptor09 in forum Access
    Replies: 1
    Last Post: 05-18-2012, 04:18 PM
  4. VBA excluding (Ignoring) Comma
    By RedWolf3x in forum Programming
    Replies: 3
    Last Post: 11-11-2011, 05:15 PM
  5. Comma
    By tmcrouse in forum Queries
    Replies: 4
    Last Post: 10-11-2011, 04:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums