請教各位
查了好多篇相關文章,但是還是無法做出來
我現在在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
就出現錯誤說~~~陣列索引超出範圍
弄了好久,把全文裡相關的連線字串全試了,就是弄不出來
請問我該如何修改呢
謝謝各位
文章標籤
全站熱搜
創作者介紹
創作者 vbqa 的頭像
vbqa

小吳 VBQA 程式設計討論

vbqa 發表在 痞客邦 留言(2) 人氣(7)