结束如果 结束子 问题......我如何结合这些代码并有一个ADD按钮,在更新任何内容之前会显示验证消息? i似乎无法正确使用它? somat总是出错?我不希望添加按钮添加任何内容,直到表单完成?Hi, I have got an ADD button with the following code: Private Sub addrec_Click()On Error GoTo Err_addrec_Click DoCmd.GoToRecord , , acNewRec Exit_addrec_Click: Exit Sub Err_addrec_Click: MsgBox Err.Description Resume Exit_addrec_Click End Sub and i have some validations through the following code: Private Sub Form_BeforeUpdate(Cancel As Integer) Dim blnValidation As BooleanDim strValidate As String strValidate = "These item(s) were not filled out and are required:" & vbCrLf & vbCrLf If IsNull(Me.username) Or Me.username = "" ThenblnValidate = TruestrValidate = strValidate & "Username" & vbCrLfEnd If If IsNull(Me.number) Or Me.number = "" ThenblnValidate = TruestrValidate = strValidate & "Number" & vbCrLfEnd If If blnValidate ThenMsgBox strValidateCancel = TrueEnd If End Sub The question...... how do i combine these codes and have an ADD button that will show a validation message before updating anything?? i cant seem to get this right? somat always goes wrong? i do not want the add button to add anything until the form is complete?推荐答案 展开 | 选择 | 换行 | 行号 谢谢Neo, 代码无效..............我试过以下....... ...我做错了什么? [HTML] Private Sub addrec_Click() ''验证检查 Dim blnValidation As Boolean Dim strValidate As String strValidate ="这些项目未填写o ut并且是必需的: &安培; vbCrLf& vbCrLf 如果是IsNull(Me.username)或Me.username =""然后 blnValidate = True strValidate = strValidate& "用户名和QUOT; &安培; vbCrLf 结束如果 如果blnValidate那么 MsgBox strValidate 否则 ''添加新记录 DoCmd.GoToRecord ,, acNewRec 结束如果 结束子[/ HTML] any1有个想法?? any1 have an idea?? 这篇关于结合代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-27 01:15