954,557 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

combo box must change the value of textbox

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

jaai
Light Poster
26 posts since Mar 2011
Reputation Points: 24
Solved Threads: 0
 

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
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
 

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

jaai
Light Poster
26 posts since Mar 2011
Reputation Points: 24
Solved Threads: 0
 

Are you using a data control or adodb (code)

AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
 

i'm using data control

jaai
Light Poster
26 posts since Mar 2011
Reputation Points: 24
Solved Threads: 0
 

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

AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
 

could you pls help me with the code

jaai
Light Poster
26 posts since Mar 2011
Reputation Points: 24
Solved Threads: 0
 

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.

AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You