4,816
社区成员
发帖
与我相关
我的任务
分享
Private Sub OpenReport()
Dim SQL As String
Dim strConnect As String
' Set cmdButton = Me.cmdMoreCustomerInfo ' Save a reference to the command button so that we can reference it later
' Create and bind the ADO Recordset object
Set m_Connection = New ADODB.Connection
Set adoRS = New ADODB.Recordset
' Open the connection
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & App.Path & "\tmp.mdb;Mode=Read"
m_Connection.Open strConnect
adoRS.Open "Select Table_test.*,Table_Con.*,Table_Data.* From Table_test,Table_Con,Table_Data", m_Connection, adOpenDynamic, adLockBatchOptimistic
' adoRS.Open "Select Table_Data.* From Table_Data", m_Connection, adOpenDynamic, adLockBatchOptimistic
m_Report.Database.SetDataSource adoRS
CRViewer1.ReportSource = m_Report ' other code modules can enable and disable it
' m_Report.PaperSize = crPaperEnvelope14 ' Set a visually pleasing paper size for the display
' If you're going to print the report, you should change the papersize to letter
RefreshViewer
CRViewer1.ViewReport
End Sub
Private Sub RefreshViewer()
Dim SQL As String
Dim Name() As String ' Used to help parse cboCustomerName.text
If CRViewer1.IsBusy Then Exit Sub ' Extra safety precaution
Screen.MousePointer = vbHourglass
SQL = "Select Table_test.*,Table_Con.*,Table_Data.* From Table_test,Table_Con,Table_Data"
adoRS.Close
adoRS.Open SQL, m_Connection, adOpenDynamic, adLockBatchOptimistic
m_Report.Database.SetDataSource adoRS
If CRViewer1.Visible Then
m_Report.ReadRecords
CRViewer1.Refresh
End If
Screen.MousePointer = vbDefault
End Sub