Link to home
Start Free TrialLog in
Avatar of critter017
critter017

asked on

Filling a DBCombo Box

Using VB4.0 Enterprise Edition
Have a database named carbo.mdb with a field named FoodType.  Set the properties in a Data Control named Data1.  When I click on properties of the DBCombo, I do not get a list of properties to set.  Using code like this:

   Set DBCombo1.RowSource = Data1

   Set DBCombo1.ListField = FoodType

produces an error.  How do I populate the DBCombo Box with the entries in the FoodType field?
Avatar of jgv
jgv

1. Set the DatabaseName (carbo.mdb) for Data1
2. Set the RecordSource (a table from carbo.mdb=FoodType?) for Data1
3. Set the RowSource (Data1) for DBCombo
4. Set the ListField (a field from FoodType table) for DBCombo

This can all be set at design time. I am using VB5 and am not sure how VB4 is setup but I hope this helps.
Avatar of critter017

ASKER

Where do I set the RowSource and ListField properties?  I do not get a property window when I click on "properties" in design view and have the DBCombo box selected.  This is my problem.  Everyone gives me the same answer, but the code does not work and I have no properties window.  What am I doing wrong?
As I've said, I have not used VB4 and am unfamiliar with it's layout. In VB5 there is a properties window at bottom-right of screen. I can show it by selecting 'View' from the menu bar then 'Properties Window' or the shortcut is F4. Right clicking on the DBCombo box and selecting 'Properties' does not show Recordsource or Listfield. The Recordsource, to my understanding, must be set at design time and that is why your code is causing an error. If this does not help then you will have to wait to hear from an expert that has used VB4. Sorry.
How about use the F2 to open the object browser to see, does there exist the two properties you needed?
With the risk of starting religeous wars....

I always populate my "lookup" Combo's and list-boxes by hand.
In VB 4 you can write a module to populate your lookup lists
and re-use these in various aplpications.
in VB5 and 6 you can write a user-control that you can re-use
in other applications.

On the other hand... This may be something between me and the data-bound-write-your-program-without-coding-and-not-having-a
-clue-about-what-happens-with-setting-1.000.000-properties-club

Good Luck :=)
Thank you "jgv".  I feel so dumb.  Obviously, I haven't been playing with Visual Basic very long to not know about the F4 shortcut.  Please redo your comment as an answer and I will be happy to award you the points.
ASKER CERTIFIED SOLUTION
Avatar of jgv
jgv

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial