MS Access,组合框,select 字段基于查询,如何对结果字段进行加权
MS Access, Combobox, select fields bases on query, How do I weight the result fields
我有一个数据库,其中会根据用户输入填充一系列组合框。
Private Sub txtUserInput_AfterUpdate()
cbo1.RowSource = "Select txtValue from tbl1 where (txtValue=" & [Forms]![Form1]![txtValue] & ")"
cbo1.Requery
End Sub
很简单。
但我希望结果的顺序可以根据我分配的权重进行更改。例如,我更新的每个实例蓝色是第一个 25% 的时间,红色是第一个 25% 的时间,黄色是第一个 50% 的时间。
编辑 1:
例如(感谢基因2):
txtValue1 Blue
txtValue1 Red
txtValue1 Yellow
txtValue2 Ford
txtValue2 Dodge
txtValue3 Violet
txtValue3 Lilly
txtValue3 Poppy
当用户在 txtValue 中输入 txtValue1 时,组合框显示为:
Blue
Red
Yellow
我希望根据我分配的概率,每次激活盒子时更改该顺序。
编辑 2:
所以 John,用户是第一次访问表单。
Blue
Red
Yellow
用户第二次转到表单。
Red
Blue
Yellow
第三次。
Yellow
Red
Blue
第四次。
Yellow
Red
Blue
谢谢!
您必须添加 ORDER BY 您分配的权重
cbo1.RowSource = "Select txtValue from tbl1 where (txtValue=" & [Forms]![Form1]![txtValue] & " ORDER BY weight)"
我有一个数据库,其中会根据用户输入填充一系列组合框。
Private Sub txtUserInput_AfterUpdate()
cbo1.RowSource = "Select txtValue from tbl1 where (txtValue=" & [Forms]![Form1]![txtValue] & ")"
cbo1.Requery
End Sub
很简单。
但我希望结果的顺序可以根据我分配的权重进行更改。例如,我更新的每个实例蓝色是第一个 25% 的时间,红色是第一个 25% 的时间,黄色是第一个 50% 的时间。
编辑 1:
例如(感谢基因2):
txtValue1 Blue
txtValue1 Red
txtValue1 Yellow
txtValue2 Ford
txtValue2 Dodge
txtValue3 Violet
txtValue3 Lilly
txtValue3 Poppy
当用户在 txtValue 中输入 txtValue1 时,组合框显示为:
Blue
Red
Yellow
我希望根据我分配的概率,每次激活盒子时更改该顺序。
编辑 2:
所以 John,用户是第一次访问表单。
Blue
Red
Yellow
用户第二次转到表单。
Red
Blue
Yellow
第三次。
Yellow
Red
Blue
第四次。
Yellow
Red
Blue
谢谢!
您必须添加 ORDER BY 您分配的权重
cbo1.RowSource = "Select txtValue from tbl1 where (txtValue=" & [Forms]![Form1]![txtValue] & " ORDER BY weight)"