Results 1 to 5 of 5
  1. #1
    Bazsl is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2016
    Posts
    47

    How show & in Label component

    I need to display some data generated in code in a Label component. The data contains an ampersand and the Label component converts the & to an underscore. Is there any way to disable this behavior for the Label component? If not, any workaround, possibly using a different component? Converting the & to && is possible as a last resort but I would rather not if there is another way? Can a TextBox be used as a non-data-bound component? If so, to which property to I assign the text to be displayed? Thanks.

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Converting the & to && is the only way I know to do this, with an actual Label.

    You can set the Value of an Unbound Textbox using its Control Source Property, in the Properties Pane (Data Tab), like this:

    = "This & That"


    using the single Ampersand.

    You can also tweak the Textbox to look more like a Label using its Special Effect Property (Properties - Format) setting it to Shadowed or Raised.

    Linq ;0)>

  3. #3
    Bazsl is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2016
    Posts
    47
    I'm new to Access and confused about how to assign a value in a variable to the ControlSource property in code. Is the following the correct syntax?

    [ATextBox].ControlSource = '="' & strVariable & '"'

    Thanks.

  4. #4
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    FWIW, using && is called 'escaping' the character. While this might be true of other characters, the ampersand is the only one I know of that requires it. Using one & is for assigning a keyboard shortcut to activate the default event for the object. So if a command button has the caption &Open, the O (the letter immediately following the &) will be underlined in form view and Alt+O will select and 'click' the button. To have "Save & Close" as a button caption requires "Save && Close". An unattached label has events, but AFAIK, they're not available by a keystroke combination even though &MyField would show as MyField.
    Last edited by Micron; 03-01-2017 at 12:53 PM. Reason: spelin
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    What is strVariable? You can't assign a sql statement to a textbox control source.
    how to assign a value in a variable to the ControlSource property in code.What does this mean? In a procedure? In the property sheet as an expression?
    Your variable should work in a procedure IF it holds the name of a field in the form's underlying record set regardless of whether or not the control is bound.
    txtMyText.Controlsource = strMyString should work - no quotes, no extra = signs. At least it does for me if this is being done on the open event.
    Last edited by Micron; 03-01-2017 at 01:15 PM. Reason: clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 1
    Last Post: 02-21-2014, 09:16 AM
  2. How to show field content in a Label?
    By robertdbuckley in forum Access
    Replies: 3
    Last Post: 05-24-2012, 04:02 AM
  3. Replies: 5
    Last Post: 05-25-2011, 02:34 PM
  4. Show label on report only if data in field
    By senna in forum Reports
    Replies: 1
    Last Post: 01-31-2011, 06:11 AM
  5. License information for this component not found
    By NickPenny in forum Programming
    Replies: 2
    Last Post: 12-17-2010, 02:06 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