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

Access Database ComboBox & TextBox

I have a form with multiple combo boxes and text boxes making an invoice.. I have the combo boxes linked to my database and I want each selection to fill a different textbox. The comboboxes fill on form load... How can I fill the textbox with the selected index from the combobox? Any help will do. I am using Visual Studio 2010 in .net not C#

twalton42
Light Poster
26 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

first, I want to clarify that visual studio 2010 is IDE application. Since vs2010 is a .net framework, you can use any programming language you want that is included within .net. maybe, your trying to say that you are using vb.net?

khentz
Junior Poster in Training
57 posts since Aug 2011
Reputation Points: 10
Solved Threads: 2
 

yes I'm using vb.net not any of the other programs in visual studio..I had said that about C# because sometimes I get relpries thinking I am so I wnted to clarify I'm using VB.Net..thank you

twalton42
Light Poster
26 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

ok. I'm also working with the same scenario, I'll share it with you later.

khentz
Junior Poster in Training
57 posts since Aug 2011
Reputation Points: 10
Solved Threads: 2
 

the hardest part I have is all the combo boxes are linked to the same table and with each selected needs to go to a seperate txtbox. Combo Boxes are ID# and the txt Boxes are Description & cost. Whatever you can come up with will be helpful. I did come up with a 2 line coed but it still changes everything else...grrr
[CODE] Private Sub ComboBox6_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox6.SelectedIndexChanged

'fills selected text box with selected row from database

IncomeCodesBindingSource1.CurrencyManager.Position = ComboBox6.SelectedIndex

txtDescription1.Text = ComboBox6.SelectedValue("Invoice_Description")

End Sub
[End Code]

twalton42
Light Poster
26 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

the information that you are using to fill the text boxes, where are they comming from?

anas alrawi
Newbie Poster
4 posts since Sep 2011
Reputation Points: 10
Solved Threads: 1
 

from the database selected row where it says (Invoice_Description) in the colum of that row

twalton42
Light Poster
26 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

Just to clarify, when you say all the combo boxes are linked to the same table that means you have a unique datatable as data source for all the comboboxes?
Or you are filling the combobox items using a datareader?

In the first scenario when you select an item in one of the comboboxes, the current record in the datatable will point the the one selected.
Then all the other selected items are bound to the same current record in the datatable. I would suggest to have separate datatables, one for each combobox.

Hope this helps

lolafuertes
Master Poster
798 posts since Oct 2008
Reputation Points: 120
Solved Threads: 167
 

I'll try this but will it work when all the combo boxes are set to the same datasource or bindingsource?

twalton42
Light Poster
26 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

You need separate datasources / binding sources for each combo.

lolafuertes
Master Poster
798 posts since Oct 2008
Reputation Points: 120
Solved Threads: 167
 

ok I got that setup now I'm being stupid. would you set in up this way?
[code]
Private Sub CBIC_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CBIC.SelectedIndexChanged

IncomeCodesBindingSource = CBIC.SelectedValue

TxtDescription.Text = CBIC.SelectedValue("Invoice_Description")

End Sub
[end code]

twalton42
Light Poster
26 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

IMO to fill the valid text you do not need the line

IncomeCodesBindingSource = CBIC.SelectedValue
lolafuertes
Master Poster
798 posts since Oct 2008
Reputation Points: 120
Solved Threads: 167
 

ok but on my selection of each combo box I need to fill the text of 2 textboxes both being filled with different colums of the row selected

twalton42
Light Poster
26 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 
I have a form with multiple combo boxes and text boxes making an invoice.. I have the combo boxes linked to my database and I want each selection to fill a different textbox. The comboboxes fill on form load... How can I fill the textbox with the selected index from the combobox? Any help will do. I am using Visual Studio 2010 in .net not C#


I suggest you to fill DataTables. Each dataTable for each comboBox (so you will have data seperated). Then you use DataBinding, which will be based on each comboBox selection.

Mitja Bonca
Nearly a Posting Maven
2,485 posts since May 2009
Reputation Points: 641
Solved Threads: 474
 

could you be so kind as to give me an example please?

twalton42
Light Poster
26 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

Actually I am lost. Do you need an example of what?

Please be so kind to consider putting all your code here and clarify wich are your expected behaviours, the expected results and the current ones.

Many thanks

lolafuertes
Master Poster
798 posts since Oct 2008
Reputation Points: 120
Solved Threads: 167
 

need an example of how to have multiple compboboxes all linked to the same dataset/bindingsouce and place selected description in selected texbox.

[CODE]
Private Sub ComboBox6_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox6.SelectedIndexChanged
'Choose selected row from database and place Discription in description textbox from Description Collum
IncomeCodesBindingSource1 = ComboBox6.SelectedValue
txtDescription1.Text = ComboBox6.SelectedValue("Invoice_Description")

End Sub


Private Sub CBIC_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CBIC.SelectedIndexChanged
'Choose selected row from database and place Discription in description textbox from Description Collum
IncomeCodesBindingSource = CBIC.SelectedValue
TxtDescription.Text = CBIC.SelectedValue("Invoice_Description")

End Sub

Private Sub ComboBox5_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox5.SelectedIndexChanged
'Choose selected row from database and place Discription in description textbox from Description Collum
Income_CodesTableAdapter2 = ComboBox5.SelectedValue
TxtDescription2.Text = ComboBox5.SelectedValue("Invoice_Description")

End Sub
[CODE]

twalton42
Light Poster
26 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

I used tab control in vb.net. when i click tab automatically number will show in textbox from database number+1. which is already stored number + 1.
for example already database invoice number stored EC000. when i click tab show the number EC001.
Am used MS-ACCESS databse. please reply with code..

siva28
Newbie Poster
22 posts since Oct 2011
Reputation Points: 8
Solved Threads: 0
 

the code is above here and I have someone working on it. When I select from the combo box it places the description in the textbox but when I select the next combo boxe it changes the first description and doesn't place the second in the second textbox

twalton42
Light Poster
26 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

@twalton42,

Mitja and I always said that you need to create separated, independent, data sources for each combo box, but you never show us how you did that.

The code you post above is not enough to see what you are doing, so we can not help further unless you create a zip with all your project and post it here.

Sorry for the inconvenience.

lolafuertes
Master Poster
798 posts since Oct 2008
Reputation Points: 120
Solved Threads: 167
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You