table bound form - making the combobox dynamic.

mrbg07546

Registered User.
Local time
Today, 13:45
Joined
Mar 13, 2012
Messages
18
Hi,

i have a table bound to a form (like a subform) - its more of a tempory table but i use it to show multiple rows on a form. i call this tbl_temp.

there is a field with a combox in it . (eg i bound the fields propertys to a combo box) - however is there a way to have new values based on another value in the row. eg each combobox has a different set of combo box listed values based based on another field in that row?

so if theres 3 rows in table - we could get 3 different combobox(at present you can only have 1 set of values)

Kind regards
 
The combo box gets values from a field. You can set the combo to show unique values to eliminate duplicates.
 
since it is a bound combobox, you can implement what you want with ease.
if the Row Source Type of your combo is Value List, you can change the row source of the combo dynamically.
example based in ID in the table:

const sRow As String = "1,2,3,4" 'default values for combobox
private sub form_load()
me.combo.rowsource = sRow
end sub

private sub form_current()
me.combo.rowsource = sRow
if me.ID = 1 then me.combo.rowsource = "one,two,three,four"
if me.ID = 2 then me.combo.rowsource = "aa, bb, cc, dd"
end sub

if the Row Source Type is Table/Query, then your just set the sql statement:

private const sRow As String = "select [field1] From table1"
private sub form_load()
me.combo.rowsource = sRow
end sub

private sub form_current()
' set to default value of combo
me.combo.rowsource=sRow
' combo value from another table
if me.ID = 1 then me.combo.rowsource = "select [field1] from otherTable;"
' combo value from same table but with criteria
if me.ID = 2 then me.combo.rowsource = "select [field1] from table1 where {condition};"
end sub
 

Users who are viewing this thread

Back
Top Bottom