Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving Partial Value of ComboBox to Database

Status
Not open for further replies.

szaunbr

Technical User
Jul 5, 2006
50
0
0
US
Hello. I am using vb 2005 express w/ sql server 2005.

I have a form with a combobox that lists several entry codes as well as the description of the entry code.

Example:

E1 - Original Entry
E2 - Re-Entry into School
etc...

All I would like to store in the DB is the first 2 characters (E1, E2, etc).

I have tried the following:
Dim entrycode As String
If ComboBox1.Text = "E1 - Original Entry" Then
entrycode = "E1"
ElseIf ComboBox1.Text = "E2 - Re-Entry into School" Then
entrycode = "E2"
End If
Me.LEADSDataSet.student_master.stu_entrycodeColumn = entrycode

but i keep getting the following error :

property stu_entrycodeColumn is read only

not sure where to go from here.
 
I'm not sure about your "property stu_entrycodeColumn is read only" problem but why don't you use a string function to get the first two characters of the combo box value instead of the If statement?

It's simpler, faster and best of all less code.
 
I think you need to populate combobox a bit diferentally. There is a valuemember and displaymember. Set the displaymember to E1, E2 values and the displamember toe the full thing. I suppose you have a tabel in your database that has a table with both values (the short and the long)?.

Christiaan Baes
Belgium

"My old site" - Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top