473,396 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

New Value added to Combo is not visible

Hi,

I have a databound Combo Box where I'm adding a new value to the database on
the Click of the button. I'm able to see the ComboText and it is writing to
the database. But when I do a refresh on the Combo I'm not able to see the
added value in the Combo.

Please assist. Below is the code where I'm adding the new value to the Combo.

---------------
Dim txtmodelname As String
txtmodelname = InputBox("Please select the model name")
cmbModel.Text = txtmodelname
Dim con As OleDbConnection
Dim cmd As OleDbCommand = New OleDbCommand
Dim da As OleDbDataAdapter
Dim sConStr As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\db1.mdb"
Dim sqlStr As String = "Insert into Names (Name,Description,TypeId)
values (?,?,1)"
con = New OleDbConnection(sConStr)
cmd.Connection = con
'MsgBox(sqlStr)
cmd.Parameters.Add("Name", txtmodelname)
cmd.Parameters.Add("Description", txtmodelname)
cmd.CommandText = sqlStr
con.Open()
cmd.ExecuteNonQuery()
con.Close()
-------------------

Rgds,
--
Sindbaad
Nov 21 '05 #1
3 1044
Sindbaad,
cmbModel.Text = txtmodelname


When this is your adding of the combobox than it is easy to tell.
\\\
cmbModel.items.add(txtmodelname)
///

I hope this helps?

Cor
Nov 21 '05 #2
Hi Cor,

Thanks for your prompt suggestion.

I actually tried that option of adding the value to the Combo List. I got an
error saying "Cannot modify the Items collection when the DataSource property
is set.". As this is data bound I can't add cmbmodel.items.add()

Any suggestions.

Rgds,
Sindbaad

"Cor Ligthert" wrote:
Sindbaad,
cmbModel.Text = txtmodelname


When this is your adding of the combobox than it is easy to tell.
\\\
cmbModel.items.add(txtmodelname)
///

I hope this helps?

Cor

Nov 21 '05 #3
SindBaad,

I first was writting that we cannot see how you add your items to the
combobox when I saw that textbox.text. So I thought that that was your entry
point.

So show what is the datasource. The proper way is than to add (or modify)
that row to the probably datatable. You are using a not normal way to update
when you are using a datatable (that is not really a problem before you
understand me wrong).

Cor
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Karl Roes | last post by:
Hi All, I have a form with a standard combo box and 5 tabs in A2003. On Form Open, I set Me.Detail.Visible = False and in the after update event of the combo set Me.Detail.Visible = True,( to...
8
by: Lyn | last post by:
Hi, Can anyone tell me how the initial value displayed in Combo Box is determined when a form is opened? I am loading the dropdown from one field ("CategoryName") of a table, with "ORDER BY ". ...
8
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...
1
by: scott_baird | last post by:
I'm sure there are easier ways, but... I have a combo box that has 5 possibilities (one of which is "sold"). When the combobox.value=Sold, I want an image to appear, otherwise to not be visible....
2
by: Susan Bricker | last post by:
Greetings. I have a form (frmDogs) that is invisible while a subsequent form (frmPeople) is visible. The visible form sets a value for a combobox (cboOwner) in the hidden form, makes the...
7
by: sara | last post by:
I have a form where the user selects an item from a list box, and then works on that item. The user chooses an AD, then opens a form to assign departments to the ad. The top of the Depts form has...
1
by: griffin700 | last post by:
hi, on my form there are 2 combos (ms access) combo1 contains values: 1, 2, 3, 4, 5 combo2 contains values: a, b, c, d, e if you choose 1 or 2 or 3 from combo1 and a or b from combo 2 it...
3
by: zufie | last post by:
How can I get the Value that I select using my Combo Box to be UNIQUE (to save to ONE record)to the respective Record that I am viewing on my Form? At present, when I select a Value from the...
1
beacon
by: beacon | last post by:
Hi everybody, I have an Employee table with the following: Table - Employee -------------------------- ID: AutoNum, PK FName: Text LName: Text Status: Yes/No
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.