发新话题
打印

[基础] VB编译时报变量未定义

VB编译时报变量未定义

我的代码:

Option Explicit
Dim ypstr, tjstr, lsstr As String
Dim hj As Integer

Dim ypconn As New ADODB.Connection
Dim cxset As ADODB.Recordset

Dim Reportrk As New CrystalReport2
Dim Reportck As New CrystalReport4



Private 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 If

If Option2.Value = True Then '出库明细
   tjstr = "select * from CKBF"
End If

sjklj (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 If



End Sub

TOP

发新话题