我做了一个学生管理系统,调试时他提示  424实时错误,要求对象
代码如下:
Dim conn As New ADODB.Connection
Dim connectionstring As String
Dim jfm As New ADODB.Recordset
Dim xsjl As New ADODB.Connection
Dim SQL As String
Private Sub Comcx_Click()
TXTCX1.Text = Trim(TXTCX1.Text)
    TXTCX2.Text = Trim(TXTCX2.Text)
    If TXTCX1.Text <> "" And TXTCX2.Text <> "" Then
        SQL = "select * from studeng where " & Combo1.Text & " like '" & TXTCX1.Text & "' and " & Combo2.Text & " like '" & TXTCX2.Text & "'"
        GoTo cont1
    End If
    If TXTCX1.Text <> "" Then
        SQL = "select * from student where " & Combo1.Text & " like '" & TXTCX1.Text & "'"
        GoTo cont1
    End If
    If TXTCX2.Text <> "" Then
        SQL = "select * from student where " & Combo2.Text & " like '" & TXTCX2.Text & "'"
        GoTo cont1
    End If
    SQL = "select * from student"
cont1:
    Set jfm = conn.Execute(SQL)
    Call Data_Display
End Sub
Private Sub ComDEL_Click()
    If TXTXH.Text = "" Then
        MsgBox "学号不能为空!", vbOKOnly, "information"
        TXTXH.SetFocus
        Exit Sub
    End If
    SQL = "delete from student where 学号='" & TXTXH.Text & "'"
    conn.Execute (SQL)
    Call Data_Display
    Call Clear
End Sub
Private Sub Comexit_Click()
Unload Me
End Sub
Private Sub Comsafe_Click()
Dim Msg As String
    Dim Sid As Integer
    Dim jfm As New ADODB.Recordset
    Dim Cj As New ADODB.Recordset
    Dim SQL As String
    'Dim xsjl As String
    '检查是否存在该学生生数据
    If TXTXH.Text = "" Then
        MsgBox "学号不能为空!", vbOKOnly, "information"
        TXTXH.SetFocus
        Exit Sub
    End If
    If IsNumeric(TXTYW.Text) = False Then
        MsgBox "语文成绩为数字,请重新输入!", vbOKOnly, "information"
        TXTYW.SetFocus
        Exit Sub
    End If
    If IsNumeric(TXTSX.Text) = False Then
        MsgBox "数学成绩为数字,请重新输入!", vbOKOnly, "information"
        TXTSX.SetFocus
        Exit Sub
    End If
    If IsNumeric(TXTEN.Text) = False Then
        MsgBox "英语成绩为数字,请重新输入!", vbOKOnly, "information"
        TxtYy.SetFocus
        Exit Sub
    End If
        
    SQL = "select 学号 from student where 学号='" & TXTXH.Text & "'"
    Set xsjl = conn.Execute(SQL)
    If xsjl.BOF And xsjl.EOF Then
        SQL = "insert into student (学号,姓名,性别,班级,联系电话,语文成绩,数学成绩,英语成绩) "
        SQL = SQL & "values ('" & TXTXH.Text & "','" & TXTXM.Text & "','" & TXTXB.Text & "','" & TXTBJ.Text & "','" & TXTDH.Text & "','" & TXTYW.Text & "','" & TXTSX.Text & "','" & TXTEN.Text & "')"
        conn.Execute (SQL)
                   
        MsgBox "存盘成功!", vbOKOnly, "information"
    Else
        SQL = "update student set 姓名='" & TXTXM.Text & "',性别='" & TXTXB.Text & "',班级='" & TXTBJ.Text & "',联系电话='" & TXTDH.Text & "',语文成绩='" & TXTYW.Text & "',数学成绩='" & TXTSX.Text & "',英语成绩='" & TXTEN.Text & "' where 学号='" & TXTXH.Text & "'"
        conn.Execute (SQL)
        MsgBox "修改成功!", vbOKOnly, "information"
    End If
    
    Call Data_Display
End Sub
Private Sub Form_Load()
Call Clear
  Call MSFG_Clear
  conn.connectionstring = "Provider=SQLOLEDB.1;Persist Security Info=False;Password=sa;user ID=sa;Initial Catalog=student;Data Source=hi"
    conn.Open
    SQL = "select * from student"
    Set jfm = conn.Execute(SQL)
    Call Data_Display
End Sub
Private Sub MSFG_Clear()
   MSFlexGrid1.ColWidth(0) = 800  (出错的地方)
    MSFlexGrid1.ColAlignment(0) = flexAlignCenterCenter
    MSFlexGrid1.ColWidth(1) = 800
    MSFlexGrid1.ColWidth(2) = 1400
    MSFlexGrid1.ColWidth(3) = 800
    MSFlexGrid1.ColWidth(4) = 1300
    MSFlexGrid1.ColWidth(5) = 1200
    MSFlexGrid1.ColWidth(6) = 1200
    MSFlexGrid1.ColWidth(7) = 1200
    MSFlexGrid1.ColWidth(8) = 1200
    MSFlexGrid1.Rows = 1
End Sub
Private Sub Clear()
    TXTXH.Text = ""
    TXTXM.Text = ""
    TXTXB.Text = ""
    TXTBJ.Text = ""
    TXTDH.Text = ""
    TXTYW.Text = ""
    TXTSX.Text = ""
    TXTEN.Text = ""
    TXTCX1.Text = ""
    Combo1.Text = "学号"
    TXTCX2.Text = ""
    Combo2.Text = "姓名"
End Sub
Private Sub Data_Display()
    Dim i As Integer
        
    MSFlexGrid1.Rows = 1 '清空表
    If (Not jfm.BOF) And (Not jfm.EOF) Then
        i = 0
        jfm.MoveFirst
        Do While Not jfm.EOF
            MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
            i = i + 1
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 0) = i
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 1) = Trim(jfm("学号"))
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 2) = Trim(jfm("姓名"))
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 3) = Trim(jfm("性别"))
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 4) = Trim(jfm("班级"))
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 5) = Trim(jfm("联系电话"))
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 6) = Trim(jfm("语文成绩"))
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 7) = Trim(jfm("数学成绩"))
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 4) = Trim(jfm("英语成绩"))
            jfm.MoveNext
        Loop
        
    End If
End Sub
Private Sub MSFlexGrid1_Click()
    TXTXH.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 1)
    TXTXM.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 2)
    TXTXB.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 3)
    TXTBJ.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 4)
    TXTDH.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 5)
    TXTYW.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 6)
    TXTSX.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 7)
    TXTEN.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 8)
End Sub
Private Sub MSFlexGrid1_RowColChange()
    Call MSFlexGrid1_Click
End Sub
那位兄弟帮帮看,问题该怎么解决..我把原代码也上传了!请帮帮忙
[此贴子已经被作者于2006-12-31 10:38:11编辑过]

 
											





 
	    
