2014-09-26 33 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