Results 1 to 11 of 11
  1. #1
    kelann is offline Learning ... thank you!!
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    132

    Calculated field (address), skipping empty lines

    Hi, all!



    I have address fields that I would like to show on a report as neatly as possible.

    I would like them to appear as shown:

    Address1
    Address2
    City, State Zip

    The things I'm unsure of how to do are the following:

    (1) Force a carriage return; and
    (2) Skip Address2 (and the carriage return that would follow it) if Address2 is empty.

    I bet this is easy, but it's a hard one to google!!!

    Thanks!

    --ak

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Concatenate fields in a single textbox with IIf.

    Address1 & Chr(13) & Chr(10) & IIf(Not IsNull(Address2), Address2 & Chr(13) & Chr(10), "") & City & ", " & State & " " & ZIP
    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.

  3. #3
    kelann is offline Learning ... thank you!!
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    132
    Thanks, June!

    For some reason, Access is beefing about the Chr(13) and Chr(10). It doesn't matter if I use & or +, it beefs at both. It doesn't matter if I use Chr(13) or Chr$(13) -- it beefs. It's fine without them, but as soon as I add them it says the expression ... cannot be used in a calculated column.

    I'm trying for a calculated text field.

    I tried it as the default value for a memo field, but it won't allow that, either -- even without chr's.

    If there is a better way -- to do it within the report rather than create a field -- I'm happy to do it that way. Just don't know how.

    Thank you again!

    --ak

  4. #4
    kelann is offline Learning ... thank you!!
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    132
    I also tried using vb constants (vbLf, vbNewLine, vbCr, and vbLineFeed), but all to no avail -- it simply deletes the shorter ones and thinks the longer ones are fields that don't exist.

  5. #5
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,067
    Hate to say this but I didn't notice it anywhere above and I spent almost 30 minutes with a similar problem a couple of years ago. When I realized it I wanted to go hide. anyway Since it's a text box and your concatenating fields make sure you didn't forget the = sign in front.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Didn't realize you were trying in Calculated field in table, haven't used those myself. Yes, put expression in textbox (I was assuming you would do that) and don't forget the equal sign as Ray pointed out.
    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.

  7. #7
    kelann is offline Learning ... thank you!!
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    132
    You are, collectively, the best!!!

    Thank you so much!

    Still learning -- didn't know I could type this stuff into a text box until just today ...

  8. #8
    kelann is offline Learning ... thank you!!
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    132
    I just wanted to thank you both again -- I am going through my tables and deleting unnecessary calculation fields and inserting them into report text boxes, instead.

    Thanks for helping me to have a cleaner database!

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    The Calculated field in table is not a terribly bad idea, however, it does make the db incompatible with Access 2007.
    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.

  10. #10
    kelann is offline Learning ... thank you!!
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    132
    Thanks, June!

    Quick question -- when I have the text box field in the report -- say

    = FirstName + " ' + Last Name

    and I have on the "Other" tab, under Name, YPLookupName.

    my EventProcedures are balking -- they are asking me forthe value of YPLookupName, as if it does not exist.

    I have YPLookupName set up this way on a form and on a report, and my SQL is:

    DoCmd.OpenReport "GetYPInfoRep", acViewPreview, , "YPLookupName = '" & Me.YPLookupName & "'"

    And it balks.

    Any thoughts?

    Thanks!

  11. #11
    kelann is offline Learning ... thank you!!
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    132
    Okay, never mind, went back to the table calcs for some of the name stuff, since it's not considered bad form. All up and running again (hooray for backups)!
    Thanks again!!

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

Similar Threads

  1. using google maps address into a text field
    By thanosgr in forum Programming
    Replies: 5
    Last Post: 04-26-2012, 03:39 PM
  2. Replies: 3
    Last Post: 12-28-2011, 01:45 PM
  3. Remove lines from Memo field
    By bvallez in forum Programming
    Replies: 5
    Last Post: 08-08-2011, 06:40 PM
  4. Replies: 4
    Last Post: 06-29-2011, 06:32 AM
  5. Input Mask for an IP Address and Mack Address
    By baksg1995 in forum Access
    Replies: 18
    Last Post: 06-23-2009, 12:33 PM

Tags for this Thread

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