By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,190 Members | 1,503 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,190 IT Pros & Developers. It's quick & easy.

How to return value in Combobox

P: n/a
Hi, I need some info

How to return the value from the database
My combobox
Me.cboTypeAdres.Items.Add("Type Adres")
Me.cboTypeAdres.Items.Add("Leverancier")
Me.cboTypeAdres.Items.Add("Klant")

the value in the database = 0 ; 1 or 2

How to return the text using the value index so that the view is the bounded
text ?

Many thanks in advance

Marc
Sep 13 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
If you don't have the ability to add the name to your Database table
then the best way to do it is set a variable equal to the combobox
SelectedIndex and send that.

Put something like this code in the click event of a btnSave:

Dim iAdresType as Integer

iAdresType = cboTypeAdres.SelectedIndex

SelectedIndex is zero based so you can put the combobox items in order
that they are on the database.

You could also use a Select Case statement that looks at the
cboTypeAdres.Text and sends the appropriate SelectedIndex.

Hope that helps!

trevisc

Scotty wrote:
Hi, I need some info

How to return the value from the database
My combobox
Me.cboTypeAdres.Items.Add("Type Adres")
Me.cboTypeAdres.Items.Add("Leverancier")
Me.cboTypeAdres.Items.Add("Klant")

the value in the database = 0 ; 1 or 2

How to return the text using the value index so that the view is the bounded
text ?

Many thanks in advance

Marc
Sep 13 '06 #2

P: n/a
Hi trevish,

Thanks for your answer,
My realy question also = how to bind directly to database, now i have a
textbox bound
Me.txtAdresType.DataBindings.Add("text", bsAdressen, "AdresType")

If I select my combo, the update in the textbox is working fine but if i
will save the data and the textbox hans't been selected the value return to
the previous old value.
How to fix?
Or how to databind the combobox "cboTypeAdres" direcly
best regards,
Marc.


"trevisc" <tr*****@gmail.comschreef in bericht
news:11**********************@i3g2000cwc.googlegro ups.com...
If you don't have the ability to add the name to your Database table
then the best way to do it is set a variable equal to the combobox
SelectedIndex and send that.

Put something like this code in the click event of a btnSave:

Dim iAdresType as Integer

iAdresType = cboTypeAdres.SelectedIndex

SelectedIndex is zero based so you can put the combobox items in order
that they are on the database.

You could also use a Select Case statement that looks at the
cboTypeAdres.Text and sends the appropriate SelectedIndex.

Hope that helps!

trevisc

Scotty wrote:
>Hi, I need some info

How to return the value from the database
My combobox
Me.cboTypeAdres.Items.Add("Type Adres")
Me.cboTypeAdres.Items.Add("Leverancier")
Me.cboTypeAdres.Items.Add("Klant")

the value in the database = 0 ; 1 or 2

How to return the text using the value index so that the view is the
bounded
text ?

Many thanks in advance

Marc

Sep 13 '06 #3

P: n/a
hmm..can you just put

cboTypeAdres.Focus() in the click event of the Save button?

still not sure if i'm understanding the problem but if by clicking in a
box it somehow refreshes your combo box then either do
cboTypeAdres.refresh or just set focus to the combobox before you run
the save routine.
If I select my combo, the update in the textbox is working fine but if i
will save the data and the textbox hans't been selected the value return to
the previous old value.
>

"trevisc" <tr*****@gmail.comschreef in bericht
news:11**********************@i3g2000cwc.googlegro ups.com...
If you don't have the ability to add the name to your Database table
then the best way to do it is set a variable equal to the combobox
SelectedIndex and send that.

Put something like this code in the click event of a btnSave:

Dim iAdresType as Integer

iAdresType = cboTypeAdres.SelectedIndex

SelectedIndex is zero based so you can put the combobox items in order
that they are on the database.

You could also use a Select Case statement that looks at the
cboTypeAdres.Text and sends the appropriate SelectedIndex.

Hope that helps!

trevisc

Scotty wrote:
Hi, I need some info

How to return the value from the database
My combobox
Me.cboTypeAdres.Items.Add("Type Adres")
Me.cboTypeAdres.Items.Add("Leverancier")
Me.cboTypeAdres.Items.Add("Klant")

the value in the database = 0 ; 1 or 2

How to return the text using the value index so that the view is the
bounded
text ?

Many thanks in advance

Marc
Sep 13 '06 #4

P: n/a
both does not work
On cboTypeAdres_SelectedIndexChanged the index value goes into
txtTypeAdress

Only after i select manualy txtTypeAdress the update function will
succeed

"trevisc" <tr*****@gmail.comschreef in bericht
news:11**********************@m73g2000cwd.googlegr oups.com...
hmm..can you just put

cboTypeAdres.Focus() in the click event of the Save button?

still not sure if i'm understanding the problem but if by clicking in a
box it somehow refreshes your combo box then either do
cboTypeAdres.refresh or just set focus to the combobox before you run
the save routine.
>If I select my combo, the update in the textbox is working fine but if i
will save the data and the textbox hans't been selected the value return
to
the previous old value.
>>

"trevisc" <tr*****@gmail.comschreef in bericht
news:11**********************@i3g2000cwc.googlegr oups.com...
If you don't have the ability to add the name to your Database table
then the best way to do it is set a variable equal to the combobox
SelectedIndex and send that.

Put something like this code in the click event of a btnSave:

Dim iAdresType as Integer

iAdresType = cboTypeAdres.SelectedIndex

SelectedIndex is zero based so you can put the combobox items in order
that they are on the database.

You could also use a Select Case statement that looks at the
cboTypeAdres.Text and sends the appropriate SelectedIndex.

Hope that helps!

trevisc

Scotty wrote:
Hi, I need some info

How to return the value from the database
My combobox
Me.cboTypeAdres.Items.Add("Type Adres")
Me.cboTypeAdres.Items.Add("Leverancier")
Me.cboTypeAdres.Items.Add("Klant")

the value in the database = 0 ; 1 or 2

How to return the text using the value index so that the view is the
bounded
text ?

Many thanks in advance

Marc

Sep 13 '06 #5

P: n/a
what about txtTypeAdress.focus() before you save?
Scotty wrote:
both does not work
On cboTypeAdres_SelectedIndexChanged the index value goes into
txtTypeAdress

Only after i select manualy txtTypeAdress the update function will
succeed

"trevisc" <tr*****@gmail.comschreef in bericht
news:11**********************@m73g2000cwd.googlegr oups.com...
hmm..can you just put

cboTypeAdres.Focus() in the click event of the Save button?

still not sure if i'm understanding the problem but if by clicking in a
box it somehow refreshes your combo box then either do
cboTypeAdres.refresh or just set focus to the combobox before you run
the save routine.
If I select my combo, the update in the textbox is working fine but if i
will save the data and the textbox hans't been selected the value return
to
the previous old value.
>

"trevisc" <tr*****@gmail.comschreef in bericht
news:11**********************@i3g2000cwc.googlegro ups.com...
If you don't have the ability to add the name to your Database table
then the best way to do it is set a variable equal to the combobox
SelectedIndex and send that.

Put something like this code in the click event of a btnSave:

Dim iAdresType as Integer

iAdresType = cboTypeAdres.SelectedIndex

SelectedIndex is zero based so you can put the combobox items in order
that they are on the database.

You could also use a Select Case statement that looks at the
cboTypeAdres.Text and sends the appropriate SelectedIndex.

Hope that helps!

trevisc

Scotty wrote:
Hi, I need some info

How to return the value from the database
My combobox
Me.cboTypeAdres.Items.Add("Type Adres")
Me.cboTypeAdres.Items.Add("Leverancier")
Me.cboTypeAdres.Items.Add("Klant")

the value in the database = 0 ; 1 or 2

How to return the text using the value index so that the view is the
bounded
text ?

Many thanks in advance

Marc
Sep 13 '06 #6

P: n/a

Hi, Ive found it, see code below
Many thx for your idea's
By adding the refrech to txtAdresType
Private Sub cboTypeAdres_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cboTypeAdres.SelectedIndexChanged

Me.txtAdresType.Text = CStr(Me.cboTypeAdres.SelectedIndex)

Me.txtAdresType.Focus()

Me.txtAdresType.Refresh()

End Sub
Marc.


"trevisc" <tr*****@gmail.comschreef in bericht
news:11********************@e3g2000cwe.googlegroup s.com...
what about txtTypeAdress.focus() before you save?
Scotty wrote:
>both does not work
On cboTypeAdres_SelectedIndexChanged the index value goes into
txtTypeAdress

Only after i select manualy txtTypeAdress the update function will
succeed

"trevisc" <tr*****@gmail.comschreef in bericht
news:11**********************@m73g2000cwd.googleg roups.com...
hmm..can you just put

cboTypeAdres.Focus() in the click event of the Save button?

still not sure if i'm understanding the problem but if by clicking in a
box it somehow refreshes your combo box then either do
cboTypeAdres.refresh or just set focus to the combobox before you run
the save routine.

If I select my combo, the update in the textbox is working fine but if
i
will save the data and the textbox hans't been selected the value
return
to
the previous old value.

"trevisc" <tr*****@gmail.comschreef in bericht
news:11**********************@i3g2000cwc.googlegr oups.com...
If you don't have the ability to add the name to your Database table
then the best way to do it is set a variable equal to the combobox
SelectedIndex and send that.

Put something like this code in the click event of a btnSave:

Dim iAdresType as Integer

iAdresType = cboTypeAdres.SelectedIndex

SelectedIndex is zero based so you can put the combobox items in
order
that they are on the database.

You could also use a Select Case statement that looks at the
cboTypeAdres.Text and sends the appropriate SelectedIndex.

Hope that helps!

trevisc

Scotty wrote:
Hi, I need some info

How to return the value from the database
My combobox
Me.cboTypeAdres.Items.Add("Type Adres")
Me.cboTypeAdres.Items.Add("Leverancier")
Me.cboTypeAdres.Items.Add("Klant")

the value in the database = 0 ; 1 or 2

How to return the text using the value index so that the view is
the
bounded
text ?

Many thanks in advance

Marc


Sep 14 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.