How to set default value of combo box to value of record in database

How to set default value of combo box to value of record in database

Post by Alejandro Mes » Tue, 23 May 2000 04:00:00



See DataCombo Control and its boundtext property.


Quote:> I have a form to permit editing of a particular record.  There is a combo
> box on the form containing values for states.  I want the combo box
> to default to the value of the state in the record contained in the
database
> when the form is opened.

> Any thought on how to do this?

> Thanks!

 
 
 

1. Populate a Combo Box with default value...

I'm new to this and i'm sure this has been asked a bunch of times before,
but I can't seem to find the answer anywhere.  Basically, I have two stored
procedures in SQL, one is called GetAllStates, which basically returns a
list of the 50 states, their abbreviation, and their ID from the database
and another called GetAllAddresses which returns all of the address data
from another table.  In the address table, I have a foreign key that returns
the id number of the state in which it is located.

I have a combo box, which I succesfully load with all of the states, and I
successfully pull the id number from the address table.  What I'm trying to
figure out, is how I can load the combo box with the states, and set the
default selected value of the combobox equal to the value of the state ID
record in the address table.  I'm aware that I can use the datacombo control
and do it by setting the properties in design time, but I'd really would
like to find out the best way to load the box through just code, and, more
importantly, the most efficient method for doing so.

Any help at all would be sincerely appreciated.  In order for me to
progress, I'm really going to need to know how to do this, and more
importantly, understand it.

A pre-emptive thanks, and if you need the code, please let me know.

Thanks,

Jim Jawn

2. Rules, Procedures, Events, etc.

3. Combo Box Default Value

4. Need Demo of PhDbase III please

5. Default value for dropdown combo list box?

6. I can't Install SQL 2000, Help!

7. Default value for Combo Box!

8. Performance

9. Use ISNULL to set the value to the default value when NULL

10. Setting Default Value to value of another column

11. Setting up default values from the passed value

12. Combo Box - Populating Values from the Database.

13. selecting records for 2nd combo box dependant on first combo box