2009-10-13 99 views
0

我有以下公式作爲分組的交叉表報表:按代碼格式化公式?

{Command.Year} & ' ' & {Command.RF Period} 

年是SMALLINT和週期是TINYINT。

的問題是,它顯示了報告:

2,009.00 9.00

數據庫值實際上:

2009年9

無法通過刪除小數格式,因爲它們在一起。

最後,我想它是:

2009年09

編輯:

我發現這個鏈接:http://www.kenhamady.com/form15.shtml

現在我的代碼看起來像這樣的時期:

WhileReadingRecords; 


StringVar text  := Totext ({Command.RF Period} , 6 , "" ) ; //put your numeric field in this line 
NumberVar end := length (text) ; 
NumberVar clip := 
(if Val (text [ end - 6 to end ]) = 0 then 1 else 0) + 
(if Val (text [ end - 5 to end ]) = 0 then 1 else 0) + 
(if Val (text [ end - 4 to end ]) = 0 then 1 else 0) + 
(if Val (text [ end - 3 to end ]) = 0 then 1 else 0) + 
(if Val (text [ end - 2 to end ]) = 0 then 1 else 0) + 
(if Val (text [ end - 1 to end ]) = 0 then 1 else 0) + 
(if Val (text [ end - 0 to end ]) = 0 then 1 else 0) ; 
text [ 1 to Length (text) - clip ] 

但是,我不使用晶體語言,我用V B.如果它不以1開始,我如何在期間前添加0?現在

的問題是,9月份(9)顯示十月十一月,,遞減後,因爲aphabetically 9談到後1

任何人?

回答

1

ToText函數對於這類事情非常有用,不需要循環。在水晶的VB語法:

Formula = ToText({Command.Year}, 0, "") & " " & ToText({Command.RF Period}, "00") 

如果{Command.Year}和{Command.RF期}是整數你描述這應該工作。