我的一个程序调试成功后,生成想相应的可执行文件,可是编译生成过程中提示CRViwer91变量未找到,可调试时没问题啊!另外水晶报表是9版的,每次退出提示水晶报表未注册,我选择的是以后注册,和这个有关系吗?
这个问题怎么解决??急!!

解决方案 »

  1.   

    1:调试时,打开捕获所有错误
    2:启用Option Explicit
    3: 应该跟这个注册没关系可能是因为某个地方写了crviewer91 ,但是调试的时候没走到这
    但是编译的时候就检测到了。
      

  2.   

    启用Option Explicit ,是不是在程序的开头加上Option Explicit ,我的含有CRViwer91的语句模块的开头有这句话!
      

  3.   

    我的代码:
    Option Explicit
    Dim ypstr, tjstr, lsstr As String
    Dim hj As IntegerDim ypconn As New ADODB.Connection
    Dim cxset As ADODB.RecordsetDim Reportrk As New CrystalReport2
    Dim Reportck As New CrystalReport4Private Sub Command1_Click()If Option1.Value = True Then '入库明细datestr = Mid(Format(Date, "YYYY-MM-DD"), 1, 4) + "." + Mid(Format(Date, "YYYY-MM-DD"), 6, 2) + "." + Mid(Format(Date, "YYYY-MM-DD"), 9, 2)
       tjstr = "select * from RKBF"
    End IfIf Option2.Value = True Then '出库明细
       tjstr = "select * from CKBF"
    End Ifsjklj (tjstr)If Not cxset.EOF Then '药品库中有数据
       
     
       If Text1.Text = "" Then
         If Check1.Value = 1 And Mid(cxset!日期, 6, 2) = Mid(Format(Date, "YYYY-MM-DD"), 6, 2) Or Check2.Value = 1 And Mid(cxset!日期, 1, 4) = Mid(Format(Date, "YYYY-MM-DD"), 1, 4) Or Check1.Value = 1 And Check2.Value = 1 And Mid(cxset!日期, 1, 7) = Mid(Format(Date, "YYYY-MM-DD"), 1, 7) Then
         
           Reportrk.Database.SetDataSource cxset
           Screen.MousePointer = vbHourglass
         CRViewer91.ReportSource = Reportrk
          CRViewer91.ViewReport
          Screen.MousePointer = vbDefault
         End If
       Else
         If Check2.Value = 1 And Mid(cxset!日期, 6, 2) = Mid(Text1.Text, 6, 2) Or Check2.Value = 1 And Mid(cxset!日期, 1, 4) = Mid(Text1.Text, 1, 4) Or Check1.Value = 1 And Check2.Value = 1 And Mid(cxset!日期, 1, 7) = Mid(Text1.Text, 1, 7) Then
           
           Reportck.Database.SetDataSource cxset
           Screen.MousePointer = vbHourglass
           CRViwer91.ReportSource = Reportck
           CRViewer91.ViewReport
           Screen.MousePointer = vbDefault
         End If
        
      End If
    Else
        MsgBox " 数据库中没有数据,不能进行统计!", 0, "提示信息"
    End IfEnd Sub
    在CRViewer91.ReportSource = Reportrk处报变量未定义。