这是我的“添加”控件代码如下:
Private Sub Command2_Click()
'Set Rst = CreateObject("ADODB.Recordset")
If (Rst.State = adStateOpen) Then
Rst.Close
End If
Rst.CursorLocation = adUseClient
Rst.Open "Select * From 同事信息", Conn, adOpenKeyset, adLockPessimistic
Rst.AddNew
Rst.Fields("姓名").Value = Text1.Text
Rst.Fields("单位名称").Value = Text2.Text
Rst.Fields("办公电话").Value = Text3.Text
Rst.Fields("办公电话二").Value = Text4.Text
Rst.Fields("手机").Value = Text5.Text
Rst.Fields("手机二").Value = Text6.Text
Rst.Fields("宅电").Value = Text7.Text
Rst.Fields("宅电二").Value = Text8.Text
Rst.Fields("电子邮箱").Value = Text9.Text
Rst.Fields("电子邮箱二").Value = Text10.Text
Rst.Fields("QQ号").Value = Text11.Text
Rst.Fields("QQ号二").Value = Text12.Text
Rst.Fields("地址").Value = Text13.Text
Rst.Fields("邮政编码").Value = Text14.Text
Rst.Fields("其他").Value = Text15.Text
Rst.Update
MsgBox "添加成功"
Text16.Text = Rst.RecordCount
CmdAdd.Visible = True
Command2.Visible = False
CmdDelete.Enabled = True
CmdPrevious.Enabled = True
CmdNext.Enabled = True
CmdFirst.Enabled = True
CmdLast.Enabled = True
End Sub
当我连接的数据库表为空记录时,则显示为:无效使用NULL!
黄条覆盖在“Text1.Text = Rst.Fields("姓名").Value”(第一字段上)
不是空记录时,则正常!