Access text box concatination

Posted on 2008-11-18
Last Modified: 2013-11-28
Real simple question.  I have a text box that sums money raised for projects.  I'd like to incorporate the label element into the text box.  My reason for this is only aesthetic--I want the full line of text to be centered, and this is not possible using a label/text box combination.  Here is what I've tried, and clearly it does not work.

="Anticipated Equity:" & Sum([CurrentAnticipatedInvestment]) &
Question by:Phereklos
    LVL 11

    Expert Comment


    ="Anticipated Equity:" & Sum([CurrentAnticipatedInvestment])
    LVL 20

    Expert Comment

    You can place this in a label or text box.  If you don't want both, eliminate one of them
    Make sure you have access to CurrentAnticipatedInvestment value.

    me.label.caption ="Anticipated Equity:" & Sum([CurrentAnticipatedInvestment])
    or me.txbox = "Anticipated Equity:" & Sum([CurrentAnticipatedInvestment])

    In design mode - center the text (either label or textbox).

    Scott C
    LVL 11

    Accepted Solution

    To clarify for you, Phereklos...

    The solution that I provided would mean that you alter what you already have in the control source of your text box.  The solution that Scott provided would be utilized in your VBA code via, most likely, the Form_Load() event.

    Private Sub Form_Load()
     Me.Label0.Caption = "Anticipated Equity: " & Sum([CurrentAnticipatedInvestment])
     Me.Text0 = "Anticipated Equity: " & Sum([CurrentAnticipatedInvestment])
    End Sub
    LVL 20

    Assisted Solution

    In addition to Sean....

    The Form  CURRENT event would be where this is placed.

    Actually, if you use a text box and put the code right in the control source it will work (right from the textbox).

    =Anticipated Equity: " & Sum([CurrentAnticipatedInvestment])

    (don't forget the "=" sign)
    and CurrentAnticipatedInvestment must be on the form (I think - even if it's visible = false)

    Scott C
    LVL 75

    Assisted Solution

    by:DatabaseMX (Joe Anderson - Access MVP)
    IF ... CurrentAnticipatedInvestment is the name of another text box (??), you cannot Sum() on controls, only the name if Fields in the underlying record source.  If this IS the name of a field, then what was first posted should work.


    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
    A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
    Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
    The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now