报告从未显示但没有错误 [英] Report never shows up but no errors

查看:61
本文介绍了报告从未显示但没有错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前从来没有这样过。我已经在Access中开发了近20年。



使用Access 2010(ADP文件)和SQL Server 2005。



我有一个带有按钮的表单,可以运行一些报告。他们都很好。它们都以类似的方式设置。当报告出现在预览中时,我会使用报告按钮隐藏表单。这个新报告的代码大约需要一分钟左右来生成结果
集。有时预览会按预期显示。但是根据完全相同的标准,有时它根本不会出现,我们会立即回到报告表格。如果没有出现,则不会产生任何错误。当我在SSMS中运行SQL查询时,它会运行
罚款并返回我期望的内容。问题只发生在strGetScannedDocTypeCode =" ADJ"



这是我的代码。我一直在使用类似的代码并且从未遇到过这个问题。


 

私人子报告_打开(取消为整数)
错误GoTo Err_Report_Open

    Dim rs As ADODB.Recordset
   设置rs =新ADODB.Recordset
    Dim sSql As String

    'cnnCurrProj.CommandTimeout = 300
    
   如果strGetScannedDocTypeCode<> " ADJ"然后
   &NBSP;
        sSql =" EXEC sp_FortisDocumentSearch_Simple" _
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &安培; " @ScannedDocTypeCode ='" &安培; strGetScannedDocTypeCode& ","," _
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &安培; " @DocTypeStartDate ='" &安培;格式(dteStartDate," mm / dd / yyyy")& ","," _
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &安培; " @DocTypeEndDate ='" &安培;格式(dteEndDate," mm / dd / yyyy")& ","," _
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &安培; " @AdjDates ='" &安培; strAdjDates& ","," _
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &安培; " @ScannedOnOrAfterDate ='" &安培;格式(dteGetDate," mm / dd / yyyy")& ","," _
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &安培; " @Counties ='" &安培;替换(strGetCounties,"'","''''")& """

&NBSP;&NBSP;&NBSP;否则
   &NBSP;
        sSql =" EXEC sp_FortisDocumentSearch_Simple" _
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &安培; " @ScannedDocTypeCode ='" &安培; strGetScannedDocTypeCode& ","," _
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &安培; " @DocTypeStartDate = NULL," _
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &安培; " @DocTypeEndDate = NULL," _
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &安培; " @AdjDates ='" &安培; strAdjDates& ","," _
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &安培; " @ScannedOnOrAfterDate ='" &安培;格式(dteGetDate," mm / dd / yyyy")& ","," _
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &安培; " @Counties ='" &安培;替换(strGetCounties,"'","''''")& """
   &NBSP;
   结束如果
   &NBSP;
    rs.Open sSql,cnnCurrProj,adOpenStatic

    Me.RecordSource = rs.Source

    DoCmd.Maximize
   &NBSP;
    rs.Close
   &NBSP;
Exit_Report_Open:
   设置rs = Nothing
   退出Sub

Err_Report_Open:
    MsgBox Err.Description& ",#" &安培; Str(Err.Number)
   恢复Exit_Report_Open

End Sub

我会注意到当strGetScannedDocTypeCode不是"ADJ"时;它总是正确运行。它的运行速度要快得多,但总会出现。只有当strGetScannedDocTypeCode =" ADJ"我们有问题。而且,这是不可预测的。
我每次都可以使用相同的标准连续运行10次,有时它可以运行,有时也不会。



<当我为这个客户端创建一个新的报告(16年)时,我通常只是复制并粘贴并对sSql变量进行适当的更改。就像我说的,它适用于应用程序中的所有其他报告(有几十个)。



我已经更改了超时。它已经是60,180,300。我已经评论过了,你可以看到它。有趣的是,即使它被注释掉了,我也可以让它有时运行,它总是需要一分钟才能运行。



这是报告中的其他代码:


 Private Sub Report_Close()
On错误GoTo Err_Report_Close

   如果strPrintPreview =" Preview"然后
       表格(strReportCallingMenu).Visible = True
   结束如果
   &NBSP;
    cnnCurrProj.CommandTimeout = 0
   &NBSP;
Exit_Report_Close:
   退出Sub

Err_Report_Close:
    MsgBox Err.Description& ",#" &安培; Str(Err.Number)
   继续Exit_Report_Close
   &NBSP;
结束子

私人子报告_NoData(取消为整数)
错误GoTo Err_Report_NoData

    MsgBox"没有指定标准的数据。"
   取消= True
   &NBSP;
Exit_Report_NoData:
   退出Sub

Err_Report_NoData:
    MsgBox Err.Description& ",#" &安培; Str(Err.Number)
   恢复Exit_Report_NoData
   &NBSP;
结束子



我创建了一个空白的新adp并将所有对象导入其中以测试是否存在任何adp损坏。这并没有解决问题。



所以关于报告业务的任何想法都不会出现,然后只是再次显示调用表单?



谢谢,



基思

解决方案

您好,


此论坛适用于一般性问题,与Microsoft Office 2010相关的反馈。由于您的问题与代码更相关,我将把它移到Access for Developers论坛:


https://social.msdn.microsoft.com/Forums/office/en-US/home?forum=accessdev


我们建议适当发布的原因是您将获得最合格的受访者群体,而定期阅读论坛的其他合作伙伴可以分享他们的知识或从您与我们的互动中学习。感谢您的理解。


Steve Fan


I've never had this happen before. I've been developing in Access for nearly 20 years.

Using Access 2010 (ADP file) and SQL Server 2005.

I have a form with buttons on it that runs some reports. They all work fine. They are all set up in a similar way. When reports appear in preview I hide the form with the report buttons. This new report's code takes about a minute or so to generate the result set. Sometimes the preview shows up as expected. But with the EXACT SAME criteria, sometimes it never appears at all and we go right back to the report form. When it doesn't appear, it does NOT generate any errors. When I run the SQL query in SSMS it runs fine and returns exactly what I expect. The problem only occurs when strGetScannedDocTypeCode = "ADJ"

Here's my code. I've been using similar code for a long time and have never run into this problem.

Private Sub Report_Open(Cancel As Integer) On Error GoTo Err_Report_Open     Dim rs As ADODB.Recordset     Set rs = New ADODB.Recordset     Dim sSql As String     'cnnCurrProj.CommandTimeout = 300          If strGetScannedDocTypeCode <> "ADJ" Then              sSql = "EXEC sp_FortisDocumentSearch_Simple " _
            & " @ScannedDocTypeCode = '" & strGetScannedDocTypeCode & "', " _
            & " @DocTypeStartDate = '" & Format(dteStartDate, "mm/dd/yyyy") & "', " _
            & " @DocTypeEndDate = '" & Format(dteEndDate, "mm/dd/yyyy") & "', " _
            & " @AdjDates = '" & strAdjDates & "', " _
            & " @ScannedOnOrAfterDate = '" & Format(dteGetDate, "mm/dd/yyyy") & "', " _
            & " @Counties = '" & Replace(strGetCounties, "'", "''''") & "'"

    Else              sSql = "EXEC sp_FortisDocumentSearch_Simple " _
            & " @ScannedDocTypeCode = '" & strGetScannedDocTypeCode & "', " _
            & " @DocTypeStartDate = NULL, " _
            & " @DocTypeEndDate = NULL, " _
            & " @AdjDates = '" & strAdjDates & "', " _
            & " @ScannedOnOrAfterDate = '" & Format(dteGetDate, "mm/dd/yyyy") & "', " _
            & " @Counties = '" & Replace(strGetCounties, "'", "''''") & "'"          End If          rs.Open sSql, cnnCurrProj, adOpenStatic     Me.RecordSource = rs.Source     DoCmd.Maximize          rs.Close      Exit_Report_Open:     Set rs = Nothing     Exit Sub Err_Report_Open:     MsgBox Err.Description & ", # " & Str(Err.Number)     Resume Exit_Report_Open End Sub

I'll note that when strGetScannedDocTypeCode is NOT "ADJ" it ALWAYS runs correctly. It runs a lot faster, but it always shows up. it's only when strGetScannedDocTypeCode = "ADJ" that we have a problem. And again, it's not predictable. I can run it 10 times in a row using the same criteria each time and sometimes it works and sometimes it doesn't.

When I create a new report for this client (of 16 years) I generally just copy and paste and make the appropriate changes to the sSql variable. And like I said, it works fine for all the other reports in the application (there are dozens).

I've changed the timeout. It's been 60, 180, 300. I've commented it out too as you can see. Interestingly, even with it commented out, I can get the thing to run sometimes and it always takes about one minute to run.

Here's the other code in the report:

Private Sub Report_Close()
On Error GoTo Err_Report_Close

    If strPrintPreview = "Preview" Then
        Forms(strReportCallingMenu).Visible = True
    End If
    
    cnnCurrProj.CommandTimeout = 0
    
Exit_Report_Close:
    Exit Sub

Err_Report_Close:
    MsgBox Err.Description & ", # " & Str(Err.Number)
    Resume Exit_Report_Close
    
End Sub

Private Sub Report_NoData(Cancel As Integer)
On Error GoTo Err_Report_NoData

    MsgBox "No data for the criteria specified."
    Cancel = True
    
Exit_Report_NoData:
    Exit Sub

Err_Report_NoData:
    MsgBox Err.Description & ", # " & Str(Err.Number)
    Resume Exit_Report_NoData
    
End Sub

I have created a blank new adp and imported all the objects into it to test to see if there was any adp corruption. That didn't solve the problem.

So any ideas about this business of the report never appearing and then just making the calling form visible again?

Thanks,

Keith

解决方案

Hi,

This forum is for general questions and feedback related to Microsoft Office 2010. Since your question is more related to code, I'll move it to the Access for Developers forum:

https://social.msdn.microsoft.com/Forums/office/en-US/home?forum=accessdev

The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

Steve Fan


这篇关于报告从未显示但没有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆