I'm new to daniweb community.it seems to be veyr useful.hope now someone wil definetely help me solve my problem in vb6.
I've a combo box that displays the name of the customers and also a text box that must display the number of the customer.. but in my project i'm able to display the name of the customer in the combo box but the value of text box is not updated.. i'm using ms access as back end.. could any one pls help me with code

AndreRet commented: 1st Post and it is your own, thanks.:) +7

You need to use the Combobox.Listindex property to determine which customer was selected -

'After opening your recordset and connection UNDER your combo click event, the following...

Dim xIndex As Integer

xIndex = Combo1.ListIndex

rs.AbsolutePosition = xIndex 'This will move to the correct recordset
Text1.Text = rs!YourFieldNameHere 'Text is added, close recordset

rs.Close

thanks for ur kind help.. i got the number of the cutomer displayed in the text box.. could u pls tell me how to add a new record to the database from the combo box..
thanks
jaai

Are you using a data control or adodb (code)

i'm using data control

I would rather use adodb code, do you know how to achieve this?

could you pls help me with the code

By using a combobox, you will only be able to add whatever is in the combo box text. If you have multiple fields, you will hjave to use text boxes to add.

Have a look at THIS thread that gives you all the connection, add, edit etc code. Just remember that the connection code is for ms sql 2000. If you are using access, the connection will differ. To get the correct connection, have a look at this link. Just select "Access" from the available options, and use the one that you will need.

Please provide the code of combo box must change the value of textbox in vb 6.0

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.