Home > Archive > Getting Started with dBASE > July 2005 > Combo Box









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Combo Box
Mike

2005-07-08, 11:23 am

new user needs help!

I'm designing a form with a combo box in it. The user will select a style. based on that style the combo box needs to use the fields in a color table as valid choices. For example, enter style G19VS. The box needs to show fields color1, color2, color
3, etc. which contain black, blue, red, etc for that particular style. There are numerous styles in the table so I need to only use the fields for that style. I've got parent-child relationship set up.

Any ideas?
Gerald Lightsey

2005-07-08, 8:24 pm

On Fri, 08 Jul 2005 12:15:18 -0400, in the dbase.getting-started group,
Mike said...
> new user needs help!
>
> I'm designing a form with a combo box in it. The user will select
> a style. based on that style the combo box needs to use the fields
> in a color table as valid choices. For example, enter style G19VS.
> The box needs to show fields color1, color2, color3, etc. which
> contain black, blue, red, etc for that particular style. There are
> numerous styles in the table so I need to only use the fields for
> that style. I've got parent-child relationship set up.
>
> Any ideas?


Untested. Modify the on-line Help example code for dataSource [options]
example to accept a parameter passed from the styles combobox to be used
to populate the datasource of colors combobox only with colors
associated with that particular style. You may need to use a second
styles query in your datamodule if you already have it tied down in
another relationship.

function SetColorBoxDataSourc
e(thisStyle)
form.aColors = new Array()
form.styles2.rowset.first()
do
if form.styles2.rowset.fields["Style"].value = thisStyle
form.aColors.add(form.styles2.rowset.fields["Color"].value)
endif
until not form.styles2.rowset.next()
form.ColorBox.dataSource := "array form.aColors"
return

Gerald
Marc Hamelin

2005-07-08, 8:24 pm

> Any ideas?

I'm not sure if I understood you well. Basically, you're saying that you
have a child "color" table with many fields named "color1", "color2",
"color3", etc. and that you need to load the color names contained within
each field into a combobox when the "style" field of the parent table is
changed, am I correct?

If so, this is what I would do: first of all, I'd use an array as the
dataSource of my combobox. Then, when the style is changed (using the
onChange event of the "style" field or something along that line), I would
repopulate the array with the colors from your child table and reload that
array as the dataSource for the combobox. It should work the way you want
it.

Hope this helps.

Marc Hamelin



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com