本来界面是这样的。但是如果我点击增加(没有输入信息),然后再点击增加
就会弹出
请问怎么修改啊。。。
Private Sub Command1_Click()
Dim i As Long
With Adodc1.Recordset
.AddNew
Text1(0).SetFocus
Set MSHFlexGrid1.DataSource = Adodc1
End With
End Sub
Private Sub Command2_Click()
Dim N1 As Integer
N1 = MsgBox("确认删除信息?", 67, "提示信息")
If N1 = vbNo Then
MsgBox "操作已被取消!", 64, "提示信息"
End If
If N1 = vbYes Then
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveNext
End If
If Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveLast
Set MSHFlexGrid1.DataSource = Adodc1
End If
End Sub
Private Sub Command3_Click()
Adodc1.Recordset.Update
Set MSHFlexGrid1.DataSource = Adodc1
End Sub
Private Sub Command4_Click()
If Text1(0).Text = "" Then
MsgBox "带“*”的信息不能为空。", vbOKOnly
Exit Sub
End If
If MsgBox("是否保存该条数据?", vbYesNo) = vbYes Then Adodc1.Recordset.Update Else Adodc1.Recordset.CancelBatch
Set MSHFlexGrid1.DataSource = Adodc1
End Sub
Private Sub Command5_Click()
Unload Me
Load MainForm
MainForm.Show
End Sub
Private Sub Form_Load()
Dim i As Long
Adodc1.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\毕业设计\数据库\Travel.accdb;Persist Security Info=False"
Adodc1.RecordSource = "select * from 导游信息表"
Set MSHFlexGrid1.DataSource = Adodc1
With Adodc1.Recordset
If .RecordCount > 0 Then
Set Combo1.DataSource = Adodc1
Combo1.DataField = .Fields(7).Name
Combo1.ListIndex = 0
End If
For i = 0 To 6
Set Text1(i).DataSource = Adodc1
Text1(i).DataField = .Fields(i).Name
Next i
If Text1(0).Text = "" Then
MsgBox "请输入导游号!", , "提示窗口"
Exit Sub
End If
End With
End Sub
还有请高手帮我看看这段还有什么错误呢。。