今天花了一整天的時間研究如何用sql將兩個動態變數範圍的資料套到datareport上,可是還是出現問題...各位高手門幫幫忙吧
以下是小弟的程式碼...
Private Sub Command1_Click()
Dim rsall As ADODB.Recordset
Dim rsRptInOut As ADODB.Recordset
Dim bdate As String '開始日期
Dim edate As String '結束日期
bdate = Text1.Text
edate = Text2.Text
Set rsRptInOut = New ADODB.Recordset
rsRptInOut.Fields.Append "wno", adVarChar
rsRptInOut.Fields.Append "tno", adVarChar
rsRptInOut.Fields.Append "fno", adVarChar
rsRptInOut.Fields.Append "btime", adDate
rsRptInOut.Fields.Append "etime", adDate
rsRptInOut.Fields.Append "stime", adVarChar
rsRptInOut.Fields.Append "money1", adInteger
rsRptInOut.Open
***下面這行發生編譯錯誤:引述不為選擇性(optional)***
Call GetInfo(rsRptInOut)
Set DataReport2.DataSource = rsRptInOut
With DataReport2.Sections("reportheader")
.Controls("label12").Caption = bdate
.Controls("label14").Caption = edate
End With
DataReport2.Show vbModal
End Sub
-----------------------------------------------
Private Sub GetInfo(rs As ADODB.Recordset, bdate As String, edate As String)
Dim rsInfo As ADODB.Recordset
Set rsInfo = New ADODB.Recordset
rsInfo.Open "select * from ball", cn
Do Until rsInfo.EOF
If (rsInfo!wno >= bdate) And (rsInfo!wno <= edate) Then
rs.AddNew
rs!wno = rsInfo!wno
rs!tno = rsInfo!tno
rs!fno = rsInfo!fno
rs!btime = rsInfo!btime
rs!etime = rsInfo!etime
rs!stime = rsInfo!stime
rs!money1 = rsInfo!money1
rs.Update
rsInfo.MoveNext
End If
Loop
rsInfo.Clone
Set rsInfo = Nothing
End Sub