473,657 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to return value in Combobox

Hi, I need some info

How to return the value from the database
My combobox
Me.cboTypeAdres .Items.Add("Typ e Adres")
Me.cboTypeAdres .Items.Add("Lev erancier")
Me.cboTypeAdres .Items.Add("Kla nt")

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
6 3496
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.Se lectedIndex

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.Te xt 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("Typ e Adres")
Me.cboTypeAdres .Items.Add("Lev erancier")
Me.cboTypeAdres .Items.Add("Kla nt")

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
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.A dd("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 "cboTypeAdr es" direcly
best regards,
Marc.


"trevisc" <tr*****@gmail. comschreef in bericht
news:11******** **************@ i3g2000cwc.goog legroups.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.Se lectedIndex

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.Te xt 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.cboTypeAdre s.Items.Add("Ty pe Adres")
Me.cboTypeAdre s.Items.Add("Le verancier")
Me.cboTypeAdre s.Items.Add("Kl ant")

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
hmm..can you just put

cboTypeAdres.Fo cus() 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.re fresh 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.goog legroups.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.Se lectedIndex

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.Te xt 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("Typ e Adres")
Me.cboTypeAdres .Items.Add("Lev erancier")
Me.cboTypeAdres .Items.Add("Kla nt")

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
both does not work
On cboTypeAdres_Se lectedIndexChan ged 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.goo glegroups.com.. .
hmm..can you just put

cboTypeAdres.Fo cus() 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.re fresh 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.goo glegroups.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.Se lectedIndex

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.Te xt 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.cboTypeAdre s.Items.Add("Ty pe Adres")
Me.cboTypeAdre s.Items.Add("Le verancier")
Me.cboTypeAdre s.Items.Add("Kl ant")

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
what about txtTypeAdress.f ocus() before you save?
Scotty wrote:
both does not work
On cboTypeAdres_Se lectedIndexChan ged 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.goo glegroups.com.. .
hmm..can you just put

cboTypeAdres.Fo cus() 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.re fresh 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.goog legroups.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.Se lectedIndex

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.Te xt 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("Typ e Adres")
Me.cboTypeAdres .Items.Add("Lev erancier")
Me.cboTypeAdres .Items.Add("Kla nt")

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

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

Me.txtAdresType .Text = CStr(Me.cboType Adres.SelectedI ndex)

Me.txtAdresType .Focus()

Me.txtAdresType .Refresh()

End Sub
Marc.


"trevisc" <tr*****@gmail. comschreef in bericht
news:11******** ************@e3 g2000cwe.google groups.com...
what about txtTypeAdress.f ocus() before you save?
Scotty wrote:
>both does not work
On cboTypeAdres_Se lectedIndexChan ged the index value goes into
txtTypeAdres s

Only after i select manualy txtTypeAdress the update function will
succeed

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

cboTypeAdres.Fo cus() 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.re fresh 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.goo glegroups.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.Se lectedIndex

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.Te xt 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.cboTypeAdre s.Items.Add("Ty pe Adres")
Me.cboTypeAdre s.Items.Add("Le verancier")
Me.cboTypeAdre s.Items.Add("Kl ant")

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2293
by: keith | last post by:
This may seem simple, but I'm having a bit of trouble figuring out exactly how to do it. I'm accessing a database through an ODBC link, and I have a query that returns only jobs completed that day (it's automatically generated). 1 user may finish 10, 20, or 50 jobs a day, but there can be at least 20-50 users per day, and they're always going to be different. The users aren't going to return, or if they do, it's always going to be under...
8
12088
by: Zlatko Matiæ | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the combobox. What is the solution? Thank you in advance.
2
14818
by: PC Datasheet | last post by:
In a form/subform I have an unbound combobox in the form header that sets the value of a field in the subform so that it does not have to be entered for each record. In the BeforeUpdate event of the combobox I have some code to check the value against some criteria and if the new selected value fails the criteria, I cancel the BeforeUpdate event. I need the combobox to return to its previous value. For example, the current value is MyValue...
3
1342
by: Mike Hoff | last post by:
Hello, I am trying to write a function that will return the value to be stored from any control based on the control's type. So for text boxes and labels it would return the text value, for list boxes the ListIndex, for combos maybe the Items data etc. with several possible return types (string, int etc). My function (that does not work) is: Public Function SaveValue(ByVal ctrlIn As Control) As VariantType
6
4905
by: Matt | last post by:
I'm not entirely sure how to describe this issue. I have a number of ComboBoxes in my application which have their text properties bound to a field in a data set. The items loaded in the ComboBox are not data bound (they just use the built in collection property of the ComboBox), and they are all set to use the DropDownList style. When moving from record to record via a BindingNavigator or a DataGridView (in master/detail format), the text...
10
2081
by: news.microsoft.com | last post by:
I am new to this so bear with me. I have a set of combo boxes. Lets call them ComboBox1 and ComboBox2. ComboBox1 items are pulled from a table. When a user selects a certain item I want to disable ComboBox2. i can make this work in Visual Web Developer, but have been unsuccessful in Visual Basic 2005.
2
8662
by: shumaker | last post by:
I have a combobox that is very much like the one found in the RSS project here: http://msdn.microsoft.com/vstudio/express/visualCSharp/learning/ My projectNameComboBox basically is filled with a list of values from a table, and as the user selects values, a datagrid displays related records from another table because it is bound via FK relationship. My table: /****** Object: Table . Script Date: 06/19/2006
2
7143
by: DesCF | last post by:
I have a textbox and a combobox on a toolstrip. The user enters either an ID in the textbox or selects a name from the combobox. When the user selects a name from the combobox the textbox is filled in automatically by setting its .Text property equal to the .SelectedValue of the combobox. When the user enters an ID in the textbox the combobox's .SelectedValue is set to the .Text value in the ID textbox. All works fine but it is ...
1
2713
by: PIERREWHY | last post by:
I have a datagridview containing a datagridviewcombobox. The combobox has a dataset containing city_name and city_id. When I select a new city_name in the combobox I would like to return the city_id corresponding to that city_name. Code: //City ComboBox comboboxCity.DataPropertyName = "city_name"; comboboxCity.HeaderText = "City"; comboboxCity.DataSource = city_table;
0
8395
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8826
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6166
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.