Private Function ViewReportWithQuery()Function ViewReportWithQuery(ReportPath As String, QueryString As String, ByRef Report As CRAXDRT.Report, ByRef ErrMsg As String) As Boolean On Error GoTo ErrHandle: Dim strCmdQuery As String Dim strReportPath As String Set Report = Application.OpenReport(ReportPath) Report.Database.Tables(1).ConnectBufferString = goConnString Report.SQLQueryString = QueryString ViewReportWithQuery = True Exit FunctionErrHandle: ViewReportWithQuery = False ErrMsg = Err.Description End Function Private Function ViewReportWithProcedure()Function ViewReportWithProcedure(ReportPath As String, ByRef Report As CRAXDRT.Report, ByRef ErrMsg As String) As Boolean On Error GoTo ErrHandle Dim strReportPath As String Set Report = Application.OpenReport(ReportPath) Report.Database.Tables(1).ConnectBufferString = goConn.ConnectionString Report.ParameterFields.GetItemByName("@ClientNo").AddCurrentValue "00000006" Report.FormulaFields.GetItemByName("PrintName").Text = " ChenYue " Set objfrmReport.Report = Report objfrmReport.Show vbModal Exit FunctionErrHandle: ErrMsg = Err.Description End FunctionPrivate Function ViewReportWithAdo()Function ViewReportWithAdo(ReportPath As String, QueryString As String, ByRef Report As CRAXDRT.Report, ByRef ErrMsg As String) As Boolean On Error GoTo ErrHandle: Dim strCmdQuery As String Dim strReportPath As String Dim Conn As New ADODB.Connection Dim AdoRec As ADODB.Recordset Set AdoRec = goConn.Execute(QueryString) Set Report = Application.OpenReport(ReportPath) Report.Database.Tables(1).ConnectBufferString = goConn.ConnectionString Report.Database.SetDataSource AdoRec ViewReportWithAdo = True Exit FunctionErrHandle: ViewReportWithAdo = False ErrMsg = Err.DescriptionEnd Function