我用了以下代码,用command5和command6是说关联出错,请问如何改呀,不懂关联????
Private Sub Command1_Click()
If Text2.Text = Empty Then
MsgBox "数据库中无记录", 0, "软件提示:"
ElseData1.Recordset.MoveFirst
End If
End SubPrivate Sub Command2_Click()
If Text2.Text = Empty Then
MsgBox "数据库中无记录", 0, "软件提示:"
Else
Data1.Recordset.MovePreviousIf Text2.Text = Empty Then
MsgBox ("已是第一条记录")
Data1.Recordset.MoveFirstEnd If
End If
End Sub
Private Sub Command3_Click()
If Text2.Text = Empty Then
MsgBox "数据库中无记录", 0, "软件提示:"
Else
Data1.Recordset.MoveNext
If Text2.Text = Empty Then
MsgBox "当前已是最后一项记录", 0, "提示:"
Data1.Recordset.MovePrevious
Else
End If
End If
End SubPrivate Sub Command4_Click()
If Text2.Text = Empty Then
MsgBox "数据库中无记录", 0, "软件提示:"
Else
Data1.Recordset.MoveLast
If Text2.Text = Empty Then
MsgBox "当前已是最后一项记录", 0, "提示:"
Else
End If
End If
End SubPrivate Sub Command5_Click()
If Text2.Text = Empty Then
MsgBox "学号不能为空", 0, "错误"Else
Data1.Recordset.AddNew
Data1.UpdateRecord
End If
End SubPrivate Sub Command6_Click()
If Text2.Text = Empty Then
MsgBox "学号不能为空!", 0, "提示:"
Else
Data1.Recordset.AddNew
Data1.Recordset.Update
MsgBox "加入数据完成", 0, "提示:"End If
End SubPrivate Sub Command7_Click()
If Text2.Text = Empty Then
MsgBox "当前没记录", 0, "提示:"
Else
Data1.Recordset.Delete
Data1.RefreshEnd If
End Sub
Private Sub Command8_Click()
End
End Sub
Private Sub ex_Click()
End
End SubPrivate Sub op_Click()
CommonDialog1.Filter = "all files|*.mdb|"
CommonDialog1.FileName = ""
CommonDialog1FilterIndex = 2
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
Data1.Connect = access
Data1.DatabaseName = CommonDialog1.FileName
Data1.Refresh
Form1.Command1.Enabled = True
Form1.Command2.Enabled = True
Form1.Command3.Enabled = True
Form1.Command4.Enabled = True
Form1.Command5.Enabled = True
Form1.Command6.Enabled = True
Form1.Command7.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
Text5.Enabled = True
Text6.Enabled = True
Text7.Enabled = True
Text8.Enabled = True
Text9.Enabled = True
Else
MsgBox ("请选择文件")
End If
End SubPrivate Sub pc_Click()
CommonDialog1.ShowSave
End SubPrivate Sub sel_Click()
Me.Hide
Form2.Show
End Sub
Private Sub Timer1_Timer()
Data1.Recordset.MoveNext
Data1.Recordset.MovePrevious
Label10.Caption = Data1.Recordset.RecordCount - 2
End SubPrivate Sub Text2_Change()
Label10.Caption = Data1.Recordset.RecordCountEnd Sub