# Re: Selection.Formula再问

Posted by SuBird on March 02, 1999 at 11:41:06:

In Reply to: Selection.Formula再问 posted by indian on March 02, 1999 at 11:18:20:

: 求救......帮忙看一下下面的程式....想不出来错在那理???
: Dim varsql As String
: Dim varsql2 As String
: varyear = Combo1.Text
: varmonth = Combo2.Text
: varsql = CStr(varyear) & "/" & CStr(varmonth) & "/1"
: varsql2 = CStr(varyear) & "/" & CStr(varmonth) + 1 & "/1"
: : CrystalReport1.ReportFileName = App.Path + "\month.rpt"
: CrystalReport1.Action = 1CrystalReport1.SelectionFormula = "{Activity Hours.Day} between " & varsql & " And " & varsql2 & " "

Re:
SelectionFormula虽然类似SQL的Where子句，但还是有些许不同，例如SelectionFormula就无Between .. and ..的写法，你必须写成
CrystalReport1.SelectionFormula = "{Activity Hours.Day} >= '" & varsql & "' And {Activity Hours.Day} <= '" & varsql2 & "'"
Try it!

Follow Ups:

- Re: Selection.Formula再问 indian 15:56:49 3/03/99 (1)
  - Re: Selection.Formula再问 SuBird 08:25:19 3/04/99 (0)