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

Combo Box Update

Status
Not open for further replies.

ca268339

Programmer
Aug 7, 2000
32
US
Is there a simple way to update a record off of a bound or unbound combo box? I normally use a bound column to a table/query when I simply want to add a new record, but if I try to change the record a new record is added. I would simply like to "edit" the record based on the original value. Unfortunately, none of the properties that I can find hold the orignial value prior to making the changes. For example, the combo box get values from a query with a single columm and one of the rows contains the value "xxx". I want to edit the "xxx" value and change it to "xxxYYY" within the combo box. Can I get the original value of "xxx" after I've changed the value within the combo box? Shouldn't the value be current within the control?

I would appreciate any and all help on this and thank you for your time in reviewing this question.
 
Hi Ca268339, what does that handle mean?

I'm not sure if I follow your question a hundred percent but I just did a test here and I think you could work off of it.

I made 1 combo (combo2) with a few values in it (yours could be data from a table) but it is not bound. Now, the field I want to modify (Text0) is a text field on the form, bound to a table.
In the after update event (Events tab, After update, "..." button to open up Visual Basic, I did this:

If strOriginal = Empty Then strOriginal = Me.Text0
Me.Text0 = strOriginal
Me.Text0 = Me.Text0 & Me.Combo2

And while in the module just below Option Compare Database
Option Explicit add:
Dim strOriginal As String

One more small thing to add, this time in the forms On Current event (same drill)...:

strOriginal = Empty

That's all I've needed to take a bound field with a value in it of "Peanut" and by choosing in the combo "Butter" get a value in the field of PeanutButter. I figured you wouldn't want to stack things so the next combo option of "AndJelly" does not give you a result of "PeanutButterAndJelly", it will only give you "PeanutAndJelly"

See if this is sort of what you want...! Gord
ghubbell@total.net
 
Thanks for the response. My handle is simply an ID that I created from a random generator. I should have been a little more clear in my description. In the past, I've always used something like you've suggested in that I would simply create an addtional text field for the value in the combo that I want to change and then assign a button to process the change. The button would simply take the contents of the combo entry and populate that into the text box. I then would save the original value so I could update the value with the new value that I've added in the text box. This has always worked, but it's several lines of code and requires setting visible controls on/off. I was really looking for a way that I could do it all within the confines of the combo box. What I was looking for was a way to get the current value of the combo box ( The box is unbound but populated by the table that I would like to update.)

Again, thanks for the tip.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top