Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2004
    Location
    Raleigh, NC
    Posts
    146

    Unanswered: Counting the number of characters in a field?

    I have two fields: "Subject" and "Body" that each contain text strings. I need a way to add up the characters (including spaces) from each field, generate a sum of the two fields, and multiply that sum by a constant (1.50). I need to output the answer into a new text box. How do I go about doing this?

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    Me.myNewTextBox = ((Len(Me.Subject) + Len(Me.Body) * 1.50)



  3. #3
    Join Date
    Sep 2004
    Location
    Raleigh, NC
    Posts
    146
    Thanks a bunch! That did exactly what I needed it to do! Now my next question:

    I need to take the text from the "Subject" field and the "Body" field and combine it into 1 string separated by a hyphen (-). I need the contents of "Subject" to be bold. The reason is that these items are classified ads going into a paper. The first few words are always bold, then theres a hyphen, then the body of the ad. I need a way at the end of each week to retreive all of the ads going in that weeks paper and copy/paste them into a layout program. Up until recently, all of the ads were typed and formatted in a Word document and I copy/pasted from there. The problem is, we couldn't count lines or generate billing information from within Word. How would I go about doing this in Access? I've tried using reports to accomplish it, but I don't think I approached it correctly. Any help would be appreciated!

  4. #4
    Join Date
    Nov 2003
    Posts
    1,487
    Combining the two TextBoxes (with a hyphen) is quite simple but you need to know know that you can not have some text bold and some text non-bold in the same textbox. Either ALL the text is bold or none of it is. The TextBox Control doesn't work that way unfortunately but a Rich TextBox can. This is a whole other kettle of fish though.

    To combine the two TextBoxes use the following line of code:

    Me.myTextBox = Me.Subject & "-" & Me.Body



  5. #5
    Join Date
    Sep 2004
    Location
    Raleigh, NC
    Posts
    146
    I was experimenting with creating a report containing the two fields (Subject and Body) individually. I lined the two fields up next to each other and then I tried to copy/paste them into Word. The formatting was a bit buggered up, but can something along these lines work if done properly? The main problem I ran into was in trying to get the hyphen in there.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •