Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Truncate contents of a field for display purposes

Status
Not open for further replies.

shanl

Technical User
Apr 2, 2007
41
0
0
US
I have a combo box that contains a person's request number and about 80 bytes of a description field. The properties on this field identifies 2 columns to show the user when he drops down the list but I only have one field bound. When selected, all that is displayed to the user is the request number. I was asked to also show the 80 bytes of the description that had been presented previously. I changed the bound column from 1 to 2 but when I tried to run it, says the field is not big enough which is correct. I don't want to enlarge the field to be as big as the description field which can be quite large. I just want the first 80 bytes to show. Is there a way to display a portion of the field.

My Record source field looks like this: Select Request, Description, assignedto from dbo.vwopenrequests where assignedto = "xyz" order by request
 
Try using column count = 2 and bound column = 1.
You can then change column size.
djj
 
Thats what I have now. With column count 2, both request number and description show when I use the drop down box but because I have one bound column, when I select the request I'm interested in, then field that shows is the request number. I want Both the Request number and description to show.
 
I'm confused as to where you are at the present, what with trying this and trying that, but this works for me.

Create your combobox (dropdown box) with your RequestNumber (the bound column) and the description field included. To set it up so that the chosen RequestNumber and first 80 characters of the Description are assigned to a field named YourCombinedField, you'd do something like this, keeping in mind that the columns are zero based. The first column, RequestNumber, is actually Column(0)and the second column, Description, is actually Column(1)

Code:
Private Sub YourComboBox_AfterUpdate()
 Me.YourCombinedField = YourComboBox.Column(0) & " " & Left(YourComboBox.Column(1), 80)
End Sub



The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Dear Missinglinq,
Thanks for the code. That was exactly what I was looking for. I decided to make a different text box to hold the contents of the DESCRIPTION field as I realized that my control source for the combo box on this form was pointing to a different table that doesn't hold the DESCRIPTION field so it didn't appear there was a way to get it to show in this same combo box once selected. On this same combo box, my row source references REQUEST NUMBER and DESCRIPTION from a view and that works fine and displays both but I didn't want to change this form to use this same view.

What I hadn't counted on was when I selected the first request number in my combo box is that it did update the DESCRIPTION field in the new text box but because it was on a continuous form, and the minute I selected my request number, the DESCRIPTION text box was updated on ALL the other records on that form with exactly the same DESCRIPTION. EEk. I tried making it a label and the same Description. Is there a way to only update the one record that I am on, when you have a continuous form that shows lots of other records.
Shan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top