Select an Item from combobox

arunakumari02

Registered User.
Local time
Today, 15:34
Joined
Jun 2, 2008
Messages
91
I have a combo box with 4 items in it.

When select an item in combo box that item should be displayed in text box.

Can anyone help me with any pseudo code.
 
in the afterupdate of the combo box put

me.yourtextboxname= me.comboname.column(whatever# the text is in)
 
I got it. I have one more issue.

me.yourtextboxname= me.comboname.column(whatever# the text is in)

In code how to select an item instead of directly writing the item value in it.
 
I guess i dont understand your question..
 
In combo box, there are X items when I click on one of item that item should be populated in the text box.

The Code I wrote but there is error that update cannot be done.

Any help please.

Code:
Public Function Update(Row As Integer)

    Dim cboCount As Integer
    Dim intX As Integer
    
       
    
    If Forms!frmChange("cboResource" & intRow).ItemSelected.count > 0 Then
    
         cboCount = Forms!frmChange.ColumnCount
         
         For intX = 0 To cboCount - 1
            
            Debug.Print Forms!Change("cboResource" & intRow).Column(intX)
            
            
            Forms!frmChange("txtResource" & intRow) = Forms!frmChange("cboResource" & intRow).Column(intX)
    
    Next
    End If
    

End Function
 
so each click is supposed to go into the same text box?
 
If the combo box bound column is the data you are trying to see, set the bound data of the text box to the same bound data of the combo box.

If not, then use rainman's first post. Well, either way you could use rainman's first post, it is hard to determine what the actual question is.

-dK
 
Hey please check the example of what I am trying to do. This is not working .

I have table Resource with field "Type"

In form i have a textbox and the combo box. The combobox should display the items in the "Type" field of the table

When I check the item in combobox that item should be selected in textbox.

Any help.
 

Attachments

Ok, Here's what you want to do:
1)Go to properties of your combo box. Under format, look at the Column Widths field and change whatever is there to 1".

2)Still on your combo box properties, click the event tab. Select After Update. Choose [Event Procedure] then click the box with the "..." in it.

3)In the VBA window that opens, paste this code in:
Private Sub cboresource_AfterUpdate()


txtresource = cboResource.Column(0)

End Sub
Now try it. That's what I did in your database and it's working for me :)
 
Here is your database with those changes made, just for reference. :)
 

Attachments

Fixed the DB and added the functionality rainman specified in accordance with the requested help.

I added extra fields to the table and the form for demonstration purposes so that when you select a record in the combo box it automatically updates 5 other controls on the form with different data depending on the data required in each control.

Check to see if this is what either of you meant.

-dK
 
Last edited:

Users who are viewing this thread

Back
Top Bottom