Results 1 to 4 of 4
  1. #1
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232

    putting two fields together

    This works but if there is no entry the “TON” and “SEER” still shows, I do not wantanything to show if nothing is selected.


    Thank you

    Equiptment: [Proposals]![Ton] & " TON " &[Proposals]![Seer] & " SEER " & [Proposals]![Stage] &" " & [Proposals]![Type]

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    in vbe (Alt-F11) , insert a new module, then paste this code,
    then you can call it from a query, or form...
    usage:

    ConcatTon([ton],[seer],[stage],[type])

    Code:
    function ConcatTon(pvTon, pvSeer, pvStage, pvType)
    dim vWord 
    
    if not isNull(pvTon) then vWord = pvTon & " TON "
    if not isNull(pvSeer) then vWord =vWord &  pvSeer & " SEER "
    if not isNull(pvStage) then vWord =vWord &  pvStage & " "
    if not isNull(pvType) then vWord =vWord &  pvType 
    
    ConcatTon = vWord
    end function

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,641
    An alternative is to use + instead of & to concatenate field with string. Concatenation using + with Null returns Null whereas concatenation with & returns the string.

    Might want to correct the spelling of Equipment to remove the extra 't'.

    Equiptment: [Proposals]![Ton] + " TON " & [Proposals]![Seer] + " SEER " & [Proposals]![Stage] + " " & [Proposals]![Type]
    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
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    Quote Originally Posted by June7 View Post
    An alternative is to use + instead of & to concatenate field with string. Concatenation using + with Null returns Null whereas concatenation with & returns the string.

    Might want to correct the spelling of Equipment to remove the extra 't'.

    Equiptment: [Proposals]![Ton] + " TON " & [Proposals]![Seer] + " SEER " & [Proposals]![Stage] + " " & [Proposals]![Type]
    This worked great. Thank you June.

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

Similar Threads

  1. Replies: 13
    Last Post: 11-30-2016, 09:59 AM
  2. Putting in safegaurd. Is it the best way.
    By Abacus1234 in forum Forms
    Replies: 5
    Last Post: 10-17-2016, 03:32 PM
  3. Replies: 4
    Last Post: 05-22-2015, 05:52 AM
  4. Help Putting Together a Project
    By dazed in forum Access
    Replies: 11
    Last Post: 12-08-2013, 11:12 AM
  5. Replies: 5
    Last Post: 02-08-2013, 11:28 AM

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