Click to See Complete Forum and Search --> : simple Questn: How to have enums in Bound CB?
Ravi Kiran
July 21st, 1999, 01:18 AM
May this is simple question:
Suppose the database has a field say Color. It is of integer type and takes values from 0-6.
I am doing a simple & direct hooking up with Data control and Bound Combo. But since 0-6 mean nothing, i want to have human readable Color names. How can i do it, w/o writing a single line of code myself?
VB 5.0 , DAO and DataCombo. I know.. the technology is old:-). Just investigating...
By writing some code, it is easy. I was wondering if it is possible to do it automatically.
Ravi Kiran
Lothar Haensler
July 21st, 1999, 01:34 AM
w/o writing a single line of code?
well, w/o writing a single line of VB code may be.
create a table "colors" that assigns a human-readable name to all color values and change your SELECT statement to join with that table.
e.g.
create table colors(colorvalue int, colorname varchar(20)
0 - red
1 - blue
and so on
know what I mean?
Ravi Kiran
July 21st, 1999, 02:43 AM
Yeah.. After that.. what?
Ok. Lets create a new table with the color ids and names. How do i make them appear in the combo? How do i make the combo select the color for a exising value of the Color field in the original table? Suppose if i change the color and click the "Next" record btn ('>') of the Data control how to make it update the database table with the new selection?
In case i confused you: here is what i mean:
Assume you have a DB already. Also lets say it has 2 tables. DataTable1 and DataTable2
DataTable1 has a ColorField which is linked to DataTble2 ( this one has color ids and names)
and a some text fields.
Put a data control in a form and hook it up to this DB and DataTable1 (recordset). Take a simple text box. Hook the datafield to some text field of this recordset. & Run.
When you click on the "Next >" / "Back <" btns of the Data control you will browse thru the records.
If you change the the text in the TB and click "<"/">" the data is automatically validated and recordset updated, if the data control's ReadOnly property is False.
So, i managed to change the DB w/o writing a single line of code. Right.
so, AS long as i just do default stuff, i dont need / shouldn't need (?!) to write code myself.
Now, in this Color ids case also, the values in the color field should be from 0-6 only. So i should provide Drop-down type combo. It has ListField, DataField. DataSource and RowSource.
I think with appropriate linking this should allow us to get the names from DataTable2 put it in the list. After User changes, get the id back (from DataTabe2) and update the original table (DataTable1, in this case).
Is this kind of thing possible w/o writing any code ourselves??
Ravi Kiran
ps: Yeah, VB code only:-)
Lothar Haensler
July 21st, 1999, 03:45 AM
>In case i confused you
... you did :-)
Sorry, I don't even understand what the problem is.
Ravi Kiran
July 21st, 1999, 04:00 AM
I am giving up!!!!!
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.