Sub clear()
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    Text5.Text = ""
    Text6.Text = Now()
End Sub
Private Sub Command1_Click()
    
    ' If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text5.Text = "" Or Text6.Text = "" Then
       ' MsgBox "请填写完整信息"
        'Text1.SetFocus
        'Text1.Text = ""
        'Text2.Text = ""
        'Text3.Text = ""
        'Text4.Text = ""
        'Text5.Text = ""
        'Text6.Text = Now()
    'Else
       Call clear
       
        Adodc1.Recordset.AddNew
        '
        'Text6.Text = Now()
        Command1.Enabled = False
        Command2.Enabled = True
    'End If
End SubPrivate Sub Command2_Click()
    
     If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text5.Text = "" Or Text6.Text = "" Then
        MsgBox "请填写完整信息"
        Text1.SetFocus
        Text1.Text = ""
        Text2.Text = ""
        Text3.Text = ""
        Text4.Text = ""
        Text5.Text = ""
        Text6.Text = Now()
    Else
        
        Adodc1.Recordset.Update
        Text1.SetFocus
        Text1.Text = ""
        Text2.Text = ""
        Text3.Text = ""
        Text4.Text = ""
        Text5.Text = ""
        Text6.Text = Now()
        Command1.Enabled = True
        Command2.Enabled = False
    End If
    'MsgBox "保存成功,请添加下一条记录", "提示"
End SubPrivate Sub Command3_Click()
        'Text1.SetFocus
       ' Text1.Text = ""
        'Text2.Text = ""
        'Text3.Text = ""
        'Text4.Text = ""
        'Text5.Text = ""
        'Text6.Text = Now()
End SubPrivate Sub Form_Load()
    Command1.Enabled = True
    Command2.Enabled = False
End Sub

解决方案 »

  1.   

    Adodc1.refresh
    Adodc1.Recordset.AddNew 
      

  2.   

    先学着使用数组控件吧 Text1(0)--Text1(5)
      

  3.   

    Private Sub Form_Load()
            Adodc1.Refresh
            Text1.SetFocus
            Text1.Text = ""
            Text2.Text = ""
            Text3.Text = ""
            Text4.Text = ""
            Text5.Text = ""
            Text6.Text = Now()

        Command1.Enabled = True
        Command2.Enabled = False
    End Sub
    加入后为何还出错???????????
    刚开始时加载!!!!!!!!
    请高手指教!!!!!11
      

  4.   

    你ADODC控件记录集属性设置的是动态的么?
      

  5.   

    补充一点:用记录集进行添加记录时尽量在打开记录集前,加一句
    if rs.state=1 then
       rs.close
    end if
      

  6.   

    还有尽量用conn.execute"",来操作数据库,记录集一般是用来查询。