2014-09-26 34 views
0

我在这里有我的MS Access报告的场景,其中特定文本框的ControlSource可以根据绑定到该报告的字段的值而变化。访问报告 - 动态设置ControlSource

例如:

If VALUE = 1 then Me.txtFeesAndExpenses.ControlSource = "The following fees for this specific scenario are " & FEE_VALUE End if

OR

If VALUE = 2 then Me.txtFeesAndExpenses.ControlSource = "The following fees for this OTHER specific scenario are " & FEE_VALUE End if

,以便正确的值被绑定到我在用,我应该把这个代码在我的报告的麻烦文本框。

回答

1

Isn'it更容易使用计算字段,并在设计模式设定ControlSource

="The following fees for " & SWITCH(VALUE=1,"THIS",value=2,"OTHER",true," ERROR ") 
    & " specific scenario are " & FEE_VALUE 
+0

好一点@ 4dmonster。我在那里举了一个例子,但我真的有一个段落可以使用。就绩效而言,可能没有什么区别? – mntyguy 2014-09-26 12:52:52

+0

@mntyguy如果你关心性能,你可能应该把它放在查询中(报告的记录源)'“以下费用为&开关(VALUE = 1,”THIS“,value = 2,”OTHER“,true ,“ERROR”) &“具体场景是”&FEE_VALUE AS [TEXT_for_FEE]'然后将'ControlSource'设置为'TEXT_for_FEE'字段 – 4dmonster 2014-09-26 19:55:47