請教各位
查了好多篇相關文章,但是還是無法做出來
我現在在VB裡,新增一個CrystalReport,那個沒有連接資料庫,就是空的而已,然後做了幾個FormulaFields
我的表單程式是
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim connstr As String, sql As String
Dim rptTest As New rptTest
Option Explicit
Private Sub Form_Load()
connstr = "provider=microsoft.jet.oledb.4.0;" & _
"data source = " & App.Path & "\Test.mdb"
Conn.Open connstr
sql = "select * from 借出 where 借還 = 'No'"
rs.CursorLocation = adUseClient
rs.Open sql, Conn, adOpenKeyset, adLockPessimistic
rptTest.Database.SetDataSource rs
With rptTest
.UnboundA1.SetUnboundFieldSource rs("書號")
.UnboundB1.SetUnboundFieldSource rs("人員")
.UnboundC1.SetUnboundFieldSource rs("借出日期")
End With
Screen.MousePointer = vbHourglass
crTest.ReportSource = rptTest
crTest.ViewReport
Screen.MousePointer = vbDefault
End Sub
我現在的問題是
每次執行到
rptTest.Database.SetDataSource rs
就出現錯誤說~~~陣列索引超出範圍
弄了好久,把全文裡相關的連線字串全試了,就是弄不出來
請問我該如何修改呢
謝謝各位
查了好多篇相關文章,但是還是無法做出來
我現在在VB裡,新增一個CrystalReport,那個沒有連接資料庫,就是空的而已,然後做了幾個FormulaFields
我的表單程式是
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim connstr As String, sql As String
Dim rptTest As New rptTest
Option Explicit
Private Sub Form_Load()
connstr = "provider=microsoft.jet.oledb.4.0;" & _
"data source = " & App.Path & "\Test.mdb"
Conn.Open connstr
sql = "select * from 借出 where 借還 = 'No'"
rs.CursorLocation = adUseClient
rs.Open sql, Conn, adOpenKeyset, adLockPessimistic
rptTest.Database.SetDataSource rs
With rptTest
.UnboundA1.SetUnboundFieldSource rs("書號")
.UnboundB1.SetUnboundFieldSource rs("人員")
.UnboundC1.SetUnboundFieldSource rs("借出日期")
End With
Screen.MousePointer = vbHourglass
crTest.ReportSource = rptTest
crTest.ViewReport
Screen.MousePointer = vbDefault
End Sub
我現在的問題是
每次執行到
rptTest.Database.SetDataSource rs
就出現錯誤說~~~陣列索引超出範圍
弄了好久,把全文裡相關的連線字串全試了,就是弄不出來
請問我該如何修改呢
謝謝各位
文章標籤
全站熱搜

rs確有資料存在? select出來的欄位有幾個?
我有用MsgBox rs.RecordCount看,它確定有資料 我選Select 書號,人員,借出日期 From ............3個欄位 然後即使用改成剩一個欄位,它還是說我~~陣列索引超出範圍 請問這是什麼原因呢,謝謝各位