Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    clrockwell15 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jun 2017
    Posts
    23

    Adding Parentheses around a field name

    What I want to do is add Parentheses around a field name in my access report, e.g., ([Wife]) with [Wife] being the field name.

  2. #2
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    You're going to need to elaborate further. A field name shouldn't have special characters such as parantheses. Is this just for display purposes? Can you show some screen shots?

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,927
    Just use & in the source to concatenate whatever you want?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    If this is really about the label in the report then no problem at all - it should work if you just enter (Wife) as the label caption. If the field name is Wife and it contains the value "Wife" then the field probably has the wrong name.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    clrockwell15 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jun 2017
    Posts
    23
    Quote Originally Posted by kd2017 View Post
    You're going to need to elaborate further. A field name shouldn't have special characters such as parantheses. Is this just for display purposes? Can you show some screen shots?

    The Profile is about the size of a business card for each member. It has an image of the member in upper left corner. The first line has the members name which is input with the following: =Trim([Last] & ", " & [First] & " " & [MI])

    The second line has the members' spouse name: [Wife] is the official field name. What I want to do is using the & and the ", put the Wife's name in Parentheses.

    Below is the layout I want


    John Doe
    (Jane Doe) This is what I want to do in the report
    Street address
    Email ID
    Occupation
    Attached Thumbnails Attached Thumbnails 034.jpg  

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,927
    In the source?, as I have already stated.
    Attached Thumbnails Attached Thumbnails Wife.PNG  
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    So you're not trying to add () around a field name. You're trying to surround the field values.
    If done in the report design I think you'd have to hide the [Wife] control and add a calculated one wherein the controlsource property would be
    ="(" & NameOfWifeControl & ")"

    However, I think the better approach is to calculate (concatenate) in the query behind the report and bind Wife control to the calculated field, which is what WGM is saying (I think). If your report is based on a table, then change it to a query. IMO all forms and reports should be based on queries and not tables anyway. You might want to use IIF to calculate that so you don't end up with () where there is no spouse.

    EDIT - If you set the textbox to 0 height and use CanGrow property, you might be able to avoid a blank line where there is no spouse. Can't recall if that property works in print preview. Or have (no spouse) if there isn't one and you don't want a blank line in any case.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Your members are all heterosexual men?
    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.

  9. #9
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Quote Originally Posted by June7 View Post
    Your members are all heterosexual men?
    I'd expect to see such a question about sexual preferences and gender posted at AWF by certain members there, but not here.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    return (wife) only if the value isn't null or spaces.
    Code:
    =IIf(Trim([Wife] & "")="","","(" & [Wife] & ")")

  11. #11
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,927
    Quote Originally Posted by June7 View Post
    Your members are all heterosexual men?
    Women have wives as well?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Quote Originally Posted by Welshgasman View Post
    Women have wives as well?
    Maybe. Or they have husbands.

    The field name [Wives] is sexist and implies the organization is as well (only male membership?) and maybe even homophobic.
    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.

  13. #13
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,927
    Quote Originally Posted by June7 View Post
    Maybe. Or they have husbands.

    The field name [Wives] is sexist and implies the organization is as well (only male membership?) and maybe even homophobic.
    Well I heard a woman say on TV, that she and her wife wanted to get a dog, so that is good enough for me.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    And some men refer to significant other as "husband". A gender neutral field name would be "Spouse" or "SigOther". Latter removes any scent of bias about gender, orientation, marital status. Shall we get into situation of multiple "SigOther" - any polygamists in the gallery?
    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.

  15. #15
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Quote Originally Posted by kd2017 View Post
    return (wife) only if the value isn't null or spaces.
    Code:
    =IIf(Trim([Wife] & "")="","","(" & [Wife] & ")")
    I suspect Trim should be in the False part as well, assuming it is needed at all.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 10-19-2016, 11:11 AM
  2. Replies: 3
    Last Post: 07-01-2016, 08:11 AM
  3. Replies: 7
    Last Post: 06-18-2014, 08:15 AM
  4. Removing text between parentheses.
    By jwhitley in forum Programming
    Replies: 3
    Last Post: 01-17-2013, 02:37 PM
  5. Replies: 1
    Last Post: 10-29-2012, 03:07 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