代码逻一塌糊涂,一个简单的赋值也能写成这样,冗余代码如此之多,条理如此混乱,能正确执行才奇怪,你还不如直接告诉你的需求,重写代码。
我帮你重写了,但是不保证正确,因为不知道你的需求:
With e.form
With e.form
If .Controls("TextBox5").Value Is Nothing Then
MsgBox("部门编号不能为空!",64, "提示")
Tables("bmgl").AllowEdit = False
Return
End If
If .Controls("TextBox6").Value Is Nothing Then
MsgBox("部门编号不能为空!",64, "提示")
Tables("bmgl").AllowEdit = False
Return
End If
If .Controls("TextBox7").value IsNot Nothing AndAlso Isnumeric( .Controls("TextBox7").value) =False Then
MsgBox("电话号码只能为数字!",64, "提示")
Tables("bmgl").AllowEdit = False
Return
End If
If Tables("bmgl").Current("bmbh") = .Controls("TextBox6").value Then
Tables("bmgl").Current("bmmc") = .Controls("TextBox5").value
Tables("bmgl").Current("bmbh")= .Controls("TextBox6").value
Tables("bmgl").Current("tel")= .Controls("TextBox7").value
Tables("bmgl").Current("mail")= .Controls("TextBox8").value
Tables("bmgl").Current("bz")= .Controls("TextBox9").value
Else
Dim r As Integer
r = Tables("bmgl").find( .Controls("TextBox6").value , 0, 0, False, False, True)
If r > -1 Then
msgbox("部门编号已存在,请更正!",64,"提示")
.Controls("TextBox6").text =Tables("bmgl").Current("bmbh")
Else
Tables("bmgl").Current("bmmc") = .Controls("TextBox5").value
Tables("bmgl").Current("bmbh")= .Controls("TextBox6").value
Tables("bmgl").Current("tel")= .Controls("TextBox7").value
Tables("bmgl").Current("mail")= .Controls("TextBox8").value
Tables("bmgl").Current("bz")= .Controls("TextBox9").value
Tables("bmgl").Current.Save
End If
End If
.Controls("TextBox5").value =""
.Controls("TextBox6").value =""
.Controls("TextBox7").value =""
.Controls("TextBox8").value =""
.Controls("TextBox9").value =""
End With
End With
[此贴子已经被作者于2015/4/19 16:01:07编辑过]