求助:如此设计有何不妥
Option ExplicitPrivate Sub Command1_Click()
Command2.Enabled = True
Data1.Recordset.AddNew '若数据库的必填字段设为"是",将会引起Required错误
Text1(0).SetFocus
End Sub
Private Sub Command2_Click()
Data1.Recordset.Update '若在没有AddNew或CancleUpdate的情况下操作Update,将会产生实时错误3032.
End Sub
Private Sub Form_Load()
Data1.DatabaseName = App.Path & "\book2.mdb" '加载时用相对路径
Command2.Enabled = False '防止产生实时错误3032
Text1(1).BackColor = &H80000001
Text1(2).BackColor = &H80000001
Text1(3).BackColor = &H80000001
Text1(4).BackColor = &H80000001
End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer) '记录输入完成后,自动移至下一输入点.
If KeyAscii = 13 Then
If Text1(0).Text <> "" And KeyAscii = 13 Then
Text1(1).SetFocus
Text1(1).BackColor = &H80000005 ' MsgBox "请输入您要增加的记录内容!", vbInformation, "提示信息"
End If
If Text1(1).Text <> "" And KeyAscii = 13 Then '这句不行 上网求助
Text1(2).SetFocus
Text1(2).BackColor = &H80000005 '因为是控件数组,实难解决
End If
If Text1(2).Text <> "" And KeyAscii = 13 Then
Text1(3).SetFocus
Text1(3).BackColor = &H80000005
End If
If Text1(3).Text <> "" And KeyAscii = 13 Then
Text1(4).SetFocus
Text1(4).BackColor = &H80000005
End If
If Text1(4).Text <> "" And KeyAscii = 13 Then
Text1(4).SetFocus
Text1(4).BackColor = &H80000005
End If
Else
MsgBox "请输入您要增加的记录内容!", vbInformation, "提示信息"
End If
End Sub
谢谢