Private Sub cmdUpdate_Click()
Dim intStatus As Integer
intStatus = 1
For Each Control In Form1
If TypeOf Control Is TextBox Then
If Trim(Control.Text) = " " Then
MsgBox "不能为空!"
intSbj = 0
Exit For
End If
End If
Next
If intStatus = 1 Then
Adodc1.Recordset.Update
MsgBox "数据已更新!"
End If
End Sub
以上是一个UPDATE键触发的事件,可是不管文本框是否为空它都会更新数据库,我觉得好象没有逻辑错误吧,哪位大侠指点一下!!
Dim intStatus As Integer
intStatus = 1
For Each Control In Form1
If TypeOf Control Is TextBox Then
If Trim(Control.Text) = " " Then
MsgBox "不能为空!"
intSbj = 0
Exit For
End If
End If
Next
If intStatus = 1 Then
Adodc1.Recordset.Update
MsgBox "数据已更新!"
End If
End Sub
以上是一个UPDATE键触发的事件,可是不管文本框是否为空它都会更新数据库,我觉得好象没有逻辑错误吧,哪位大侠指点一下!!
Dim intStatus As Integer
intStatus = 1
For Each Control In Form1
If TypeOf Control Is TextBox Then
If Trim(Control.Text) = "" Then
MsgBox "不能为空!"
intStatus = 0
Exit For
End If
End If
Next
If intStatus = 1 Then
Adodc1.Recordset.Update
MsgBox "数据已更新!"
End If
End Sub
我只是猜想,到现在用了VB个把月了,我还是不习惯用它来做数据库界面,
所以具体的也不大清楚,只能提个猜想了,因为我碰到过text设定了长度而判断不了的情况。
要不就采用一个中间变量。
我试过了
不会出现你说的问题