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

Votes + Comments
1st Post and it is your own, thanks.:)
7 Years
Discussion Span
Last Post by santhanakrishnan

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


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..


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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.