Hi
I have an application in VB6 using ADODC. I am tryng to Add a record to the database. I have ADD,DELETE,CHANGE,CANCEL,SAVE and EXIT buttons on the form. When adding a new record I am disabling ADD,DELETE,CHANGE. I have put the following code in validate event of a text control. If I want to cancel the ADD operation I click on CANCEL button. But the validate event gets fired even if try to click on any button. Is there any way that I can click on CANCEL, EXIT buttons if I do not want the ADD operation without having the validate even fired.
Private Sub txtLastName_Validate(Cancel As Boolean)
Dim sCheckLastName As String
If bAddNew = True Or bEdit = True Then
sCheckLastName = txtLastName.Text
If Len(Trim(sCheckLastName)) = 0 Then
MsgBox "Last Name cannot be blank.", _
vbExclamation + vbOKOnly, "Data Entry"
Cancel = True
End If
End If
End Sub
[sig][/sig]
I have an application in VB6 using ADODC. I am tryng to Add a record to the database. I have ADD,DELETE,CHANGE,CANCEL,SAVE and EXIT buttons on the form. When adding a new record I am disabling ADD,DELETE,CHANGE. I have put the following code in validate event of a text control. If I want to cancel the ADD operation I click on CANCEL button. But the validate event gets fired even if try to click on any button. Is there any way that I can click on CANCEL, EXIT buttons if I do not want the ADD operation without having the validate even fired.
Private Sub txtLastName_Validate(Cancel As Boolean)
Dim sCheckLastName As String
If bAddNew = True Or bEdit = True Then
sCheckLastName = txtLastName.Text
If Len(Trim(sCheckLastName)) = 0 Then
MsgBox "Last Name cannot be blank.", _
vbExclamation + vbOKOnly, "Data Entry"
Cancel = True
End If
End If
End Sub
[sig][/sig]