rivate Sub Command1_Click()
  If Command1.Caption = "添 加" Then
     Command1.Caption = "确 定"
     Adodc1.Recordset.AddNew
     Text1(0).SetFocus
  Else
     Command1.Caption = "添 加"
     Adodc1.Recordset(0) = Text1(0).Text  ---黄字
     Adodc1.Recordset(1) = Text1(2).Text
     Adodc1.Recordset.Update
     MsgBox "记录添加成功!"
  End If
  
  

解决方案 »

  1.   

    Private Sub Command1_Click()    If Command1.Caption = "添 加" Then
            Command1.Caption = "确 定"
            Text1(0).SetFocus
        Else
            Command1.Caption = "添 加"
            Adodc1.Recordset.AddNew     '这个不应该分开
            Adodc1.Recordset(0) = Text1(0).Text - --黄字
            Adodc1.Recordset(1) = Text1(2).Text
            Adodc1.Recordset.Update
            MsgBox "记录添加成功!"
        End If
    End Sub
      

  2.   

    现在是
    Private Sub Command1_Click()
      If Command1.Caption = "添 加" Then
         Command1.Caption = "确 定"
         Text1(0).SetFocus
      Else
         Command1.Caption = "添 加"
         Adodc1.Recordset.AddNew
         Adodc1.Recordset(0) = Text1(0).Text
         Adodc1.Recordset(1) = Text1(2).Text
         Adodc1.Recordset.Update
         MsgBox "记录添加成功!"
      End If
      
      
    End Sub
    多步操作产生错误 请检查每一步状态值
      

  3.   

    主键是 access里面的主键吗?
      

  4.   

    把Adodc1.Recordset.Update
    换掉啊
      

  5.   

    换了! 可以还是 BOF 或 EOF 中有一个是“真”  
    Private Sub Command1_Click()
      If Command1.Caption = "添 加" Then
         Command1.Caption = "确 定"
         Adodc1.Recordset.AddNew
         Text1(0).SetFocus
      Else
         Command1.Caption = "添 加"
         Adodc1.Recordset(0) = Text1(0).Text
         Adodc1.Recordset(1) = Text1(2).Text
         Adodc1.Recordset.UpdateBatch
         MsgBox "记录添加成功!"
      End If
      
      
    End Sub
      

  6.   

    BOF 或 EOF 中有一个是“真” 说明你移动过头了
      

  7.   

    Private Sub Data1_Validate(Action As Integer, Save As Integer)End SubPrivate Sub Command1_Click()
      If Command1.Caption = "添 加" Then
         Command1.Caption = "确 定"
         Adodc1.Recordset.AddNew
         Text1(0).SetFocus
      Else
         Command1.Caption = "添 加"
         Adodc1.Recordset(0) = Text1(0).Text
         Adodc1.Recordset(1) = Text1(2).Text
         Adodc1.Recordset.UpdateBatch
         MsgBox "记录添加成功!"
      End If
      
      
    End SubPrivate Sub Command2_Click()
      Adodc1.Recordset.MoveFirst
      xh = InputBox("请输入你要修改的学生学号:", "学生的性别将修改为相反性别!")
      If xh <> "" Then
        fi = "学号=" & Trim(xh)
        Adodc1.Recordset.Find (fi)
        If Not Adodc1.Recordset.EOF Then
          q2 = MsgBox("你真的要修改学号为:" & xh & " 的学生的性别吗?", 36)
           If q2 = 6 Then '点击是按钮值为6
              If Adodc1.Recordset.Fields(2) = "男" Then
                  Adodc1.Recordset.Fields(2) = "女"
              Else
                  Adodc1.Recordset.Fields(2) = "男"
              End If
              MsgBox "性别修改成功!"
              Adodc1.Recordset.Update
           Else
              MsgBox "性别修改失败!"
           End If
        Else
          MsgBox "查无此人!"
        End If
      Else
        MsgBox "请输入正确的学号!"
      End If
    End SubPrivate Sub Command3_Click()
     Adodc1.Recordset.MoveFirst
      xh2 = InputBox("请输入你要删除的学生学号:")
      If xh2 <> "" Then
         fi2 = "学号=" & Trim(xh2)
         Adodc1.Recordset.Find (fi2)
         If Adodc1.Recordset.EOF Then
           MsgBox "查无此人!"
         Else
           q1 = MsgBox("你真的要删除 学号为:" & xh2 & " 的学生吗?", 36)
           If q1 = 6 Then '点击是按钮值为6
             Adodc1.Recordset.Delete
             Adodc1.Recordset.Update
             Adodc1.Recordset.MoveFirst
             MsgBox "记录删除成功!"
           Else
             MsgBox "记录删除失败!"
           End If
         End If
      Else
        MsgBox "请输入正确学号!"
      End If
    End SubPrivate Sub Command4_Click()
      tj.Show
    End Sub帮我看看吧
      

  8.   

    使用ADODB吧,怎么还在使用Adodc呢?
      

  9.   

    嗯 我抄另一个的 不过他是用代码连接记录集 我是VB里面连接 Adodc
      

  10.   

    Private Sub Command1_Click()
      If Command1.Caption = "添 加" Then
      Command1.Caption = "确 定"  Text1(0).SetFocus
      Else
      Command1.Caption = "添 加"
      Adodc1.Recordset.AddNew
      Adodc1.Recordset(0) = Text1(0).Text
      Adodc1.Recordset(1) = Text1(2).Text
      Adodc1.Recordset.UpdateBatch
      MsgBox "记录添加成功!"
      End If
    注意字段类型
       
       
    End Sub
      

  11.   


    Private Sub Command1_Click()
      If Adodc1.Recordset = Nothing Then
        MsgBox "记录集没有打开!"
        Exit Sub
      End If  If Command1.Caption = "添 加" Then
        Command1.Caption = "确 定"
        Text1(0).SetFocus
      Else
        Adodc1.Recordset.AddNew
        Adodc1.Recordset(0) = Text1(0).Text
        Adodc1.Recordset(1) = Text1(2).Text
        Adodc1.Recordset.Update
        MsgBox "记录添加成功!"
        Command1.Caption = "添 加"
      End If
    End Sub