Are you using a TComboBox or a TDBComboBox? If you want to display something different than what will be stored in the database (like an enumerated field) then I'd suggest using the RxDBComboBox in the RXLib
Thanks, but I would rather not download any new components as of yet. I am using Delphi 1.0 as well...
I managed to insert a TDBLookupCombo box, and this appears to be pulling back the data from the table. Within the Object Inspector, I had to specify a Lookup Source, Field, and Display, and I have left the "Data Source" section blank. I hope that this is ok....
What you are probably looking for is a DBLookupComboBox. I'm not sure if that control is available in D1 or not. If not, you will probably have to populate the drop-down with code.
Most data aware controls are designed to show the current record in a dataset. The DBLookupComboBox and DBLookupListBox need two datasets, one to populate the dropdown and one dataset controls what value is selected from the dropdown.
I am using the DBLookupComboBox now, and I am able to populate the box with values from a table without using code.
I guess the last question I have is within the OBject Inspector, I did not specify a Data Source, but I did specify a Lookup Source. Is this ok when I want to pull values from what the user selects from the combo box?
If you don't specify a datasource then a data-aware control won't work. It won't let you type anything or select anything from the drop-down. If you aren't editing a dataset with your data-aware control, then you will need to use a normal combo and populate it by hand.
But it does let me select from the drop down. I am able to select a populate table value from the drop down box.
What I am planning to do is get the user to select from the drop down box, and then whatever value she selects, use that value to post to another table...
It may be too late in terms of design but you might want to consider making your form not attached to the database directly. Use regular control and use underling code to reset text boxes, combo boxes, etc. to the values of the current record, validate user input, post and delete records.
It's more coding but it separates your interface from your programming logic which means that you don't have to fiddle with the eccentricities of DBLookupCombos (which drive me nuts X-) ). You can then use any kind of control to process the user's input and do any kind of validation before you allow the record to be added to the database.
It can be a pain the rump but the benefits are there for moving to later versions of Delphi later on since you can change the form without affecting your logic.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.