Basing textbox on choice from combo box.

t3nchi

Registered User.
Local time
Today, 05:12
Joined
Sep 28, 2005
Messages
79
I read this article for combo based on combo.
http://office.microsoft.com/en-us/assistance/HA011730581033.aspx

But now I have a textbox whose contents I want to change based on a choice in a combobox.

I don't know the code for it. Anyone can help me out some?

I went to the combo box and tried to create some code in AfterUpdates that was similar to the combo-combo one. Requery. I think I have the right idea but since I'm a VBA newbie,I don't know how to get it right.

Thanks.
 
I dont know what you want but here's a simple thing:

Me.txtYourTextBox.Value = Me.cboYourComboBox.Value * 10


Textboxes can only hold one value. Therefore a query won't be possible. To perform a query and get the specific value, you'd have to do create a DAO.Recordset and get the value from that... or you would have to use the DLookup() function.

Otherwise, be a little more specific on what you want to do. i.e. give examples and not webpages
 
Last edited:
Well, this is what I'm trying to do. Sorry I wasn't clearer.

I have a combo box with a list of things (A,B,C etc)

"A" has a corresponding message that is associated with it.
"B" has a corresponding message.

When I select from the list (eg...I choose "B"), I want a certain text box to change to the right corresponding message. I want this to happen everytime I select something different from the list (A,B,C...)

How do I do that?
 
Last edited:
Put your code in the combo box's _Change event. Example:

Code:
Public Sub ComboBox_Change()
    Select Case Me.ComboBox.Value
        Case "A": strValue = "You Chose A"
        Case "B": strValue = "You Chose B"
        Case "C": strValue = "You Chose C"
    End Select
    
    Me.TextBox.Value = strValue
End Sub
 
That's if you know you have A,B,C and you have to actually go back in and edit the code if you add D,E,F right?
 
Private Sub CategoryAfterUpdate()
Me.Product = Null
Me.Product.Requery
Me.Product = Me.Product.ItemData(0)
End Sub

If I choose a Category from the combo box, it gives me a group of Products associated with the Category (in another combo)

Now I want to choose a Product, and I want the rest of the my info in the form to change to the specifics of the product (these specifics are in text boxes). I realize it could be a variation of the above code, or is it?
 

Users who are viewing this thread

Back
Top Bottom