问题:“对象变量或with块变量未设置”
问题:“对象变量或with块变量未设置”Private Sub Command2_Click()
Dim j As Integer
Dim txtSQL As String
If Text1(5) <> Label2(5).Caption Then
If IsDate(Text1(5)) = False Then
MsgBox "起始日期应为日期格式(yyyy-mm-dd)!", vbOKOnly, "警告"
Text1(5).SetFocus
Exit Sub
Else
Text1(5) = Format(Text1(5), "yyyy-mm-dd")
End If
End If
If Text1(6) <> Label2(6).Caption Then
If IsDate(Text1(6)) = False Then
MsgBox "起始日期应为日期格式(yyyy-mm-dd)!", vbOKOnly, "警告"
Text1(6).SetFocus
Exit Sub
Else
Text1(6) = Format(Text1(6), "yyyy-mm-dd")
End If
End If
txtSQL = "select * from student_Form"
If Text1(0) <> Label2(0).Caption Then
txtSQL = txtSQL & " where student_NO='" & Trim(Text1(0)) & "'"
End If
If Text1(1) <> Label2(1).Caption Then
If txtSQL = "select * from student_Form" Then
txtSQL = txtSQL & " where student_Name='" & Trim(Text1(1)) & "'"
Else
txtSQL = txtSQL & " and student_Name='" & Trim(Text1(1)) & "'"
End If
End If
If Text1(4) <> Label2(4).Caption Then
If txtSQL = "select * from student_Form" Then
txtSQL = txtSQL & " where student_Cla='" & Trim(Text1(4)) & "'"
Else
txtSQL = txtSQL & " and student_Cla='" & Trim(Text1(4)) & "'"
End If
End If
If Text1(5) <> Label2(5).Caption And Text1(6) <> Label2(6).Caption Then
If txtSQL = "select * from student_Form" Then
txtSQL = txtSQL & " where Format(student_Esd,'yyyy-mm-dd') >='" & Trim(Text1(5)) & "'and Format(student_Esd,'yyyy-mm-dd') <='" & Trim(Text1(6)) & "'"
Else
txtSQL = txtSQL & " and Format(student_Esd,'yyyy-mm-dd') >='" & Trim(Text1(5)) & "'and Format(student_Esd,'yyyy-mm-dd') <='" & Trim(Text1(6)) & "'"
End If
End If
Set mrc = ExecuteSQL(txtSQL, MsgText)
j = 1
Do While Not mrc.EOF
j = j + 1
mrc.MoveNext
Loop
ProgressBar1.Visible = True
ProgressBar1.Min = CInt(0)
ProgressBar1.Max = CInt(j)
Set mrc = ExecuteSQL(txtSQL, MsgText)
Frame1.Visible = True
With MSFlexGrid1
.Visible = False
.Rows = 1
ProgressBar1.Value = .Rows
Do While Not mrc.EOF
.Rows = .Rows + 1
For i = 0 To mrc.Fields.Count - 1
Select Case mrc.Fields(i).Type
Case adDBDate
.TextMatrix(.Rows - 1, i) = Format(mrc.Fields(i) & "", "yyyy-mm-dd")
Case Else
.TextMatrix(.Rows - 1, i) = mrc.Fields(i) & ""
End Select
Next i
mrc.MoveNext
Loop
.Visible = True
End With
Frame1.Visible = False
mrc.Close
TextDcolor
Text1(4).Visible = True
Combo1.Visible = False
Text1(2).Enabled = False
Text1(3).Enabled = False
Text1(7).Enabled = False
Text1(8).Enabled = False
End Sub