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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box Populates Text Box incorrectly 2

Status
Not open for further replies.

fockewulf190

Technical User
Jan 2, 2003
23
US
Hello, I have tried to populate a text box based off what is selected from one of my combo boxes. I used help from this link The information worked fine except that the data that shows up in the text box isn't all of the data that should show up. Could it be that there is a 255 character limit in a combo box when setting it's selections? If that's the case I really need a way around this.

Thanks

Charles
 
If you are trying to populate a text box with a memo field from an extra column in the combobox, yes, you are correct that you are only getting the first 255 characters.

Be a little more specific as to what you are doing to receive more specific help in solving the problem. There are ways to retrieve the memo field. Through code in the combobox's afterupdate event procedure we can perform a Dlookup of the selected record identifier and assign the memofield text to your textbox.

Post back if you need more assistance.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
How are ya fockewulf190 . . . .

Your probably not showing all the columns. Just so ya see them all.

[purple]Column Count[/purple] should be 4.
[purple]Column Widths[/purple] to start should be 1";1";1";1"
[purple]List Width[/purple] should be the a min sum of Column Widths 4.

Adjust the [purple]Column Widths[/purple] to tidy things up, using zero to hide a column. Remembering to compensate your [purple]List Width[/purple].

Remember, [purple]the first Column Width not set to zero, is what appears in the textbox portion[/purple] of the Combobox.

cal.gif
See Ya! . . . . . .
 
Bob,

You seem to know what I'm trying to do. I've created a form that has 2 combo boxes and one text box. The second combo box is based on the results of combo box one. I want the text in the text box to be taken from a seperate table based on what is chosen in combo box 2(the source data for combo box 1 is from one table while the data for combo box 2 is from another table). I got this to work but the text in the text box is limited and I believe this is do to the fact that the combo box will only allow 255 characters per column. I have combo box 2 based of a query that pulls information from a table for column one and column 2....column 2 is hidden but is the source for the text box. A memo field is used as the source for what is in column 2 of the combo box.

How can I get around the 255 character limit in the combo box?
Thanks

Charles
 
Make sure you have included as a column, the unique record identifier for your table in combobox2. It is recommended that you use the AutoNumber field if possibile. In the AfterUpdate event procedure we can go one of two ways. I am a little hesitatant to recommend a DLookUp function command because it may also limit the full memofield from being returned. But I will provide it for you and you can give it a try. The second option is to open a recordset and assigne the memofield value to your textbox.

Option 1: DLookUp Function Option
AfterUpdate Event Procedure
Code:
Me![[i]text_memo_field[/i]] = DLookUp("[[i]memofield[/i]]", "[[i]tablename[/i]]", "[[i]unique_field[/i]] = " & Me![Combo2].Column([red]x[/red]))

Option 2: Recordset Option
AfterUpdate Event Procedure
Code:
Dim db as DAO.Database
Dim rs as DAO.Recordset
Set db = CurrentDB
Set rs = db.OpenRecordSet("[i]tablename[/i]", dbOpenDynaset)
rs.FindFirst "[[i]unique_field[/i]] = " & Me![Combo2].Column([red]x[/red])
If Not rs.NoMatch then
   Me![[i]text_memo_field[/i]] = rs("[i]MemoField[/i]")
else
   MsgBox "No match found for combo selection"
end if
rs.close
db.close

With both of these options you are using the unique identifier from a column in the combobox to find the record in the table and return the full MemoField text.

Post back with any questions.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
Nice Bob....Thanks!!!! I took your advice and went with the Recordset option. Have a star bud.

Charles
 
Thanks for the Star. Glad to be of help.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top