G
Gator
When the user clicks OK, data is inserted into a record...unless the date
field is empty...then a msgbox prompts for the date and the insert should
cancel.
the following msgbox prompts correctly but when I click OK, the record is
created anyway, why is this happening?
Private Sub Command17_Click()
If IsNull(Text21) Then
MsgBox "Enter a Date on Top", vbOKOnly, Date
Cancel = True
Me.Text21.SetFocus
End If
Dim mycon As New ADODB.Connection
Dim ADOrs As New ADODB.Recordset
Set mycon = CurrentProject.Connection
ADOrs.Open "TreasurerDeposits", mycon, adOpenKeyset, adLockOptimistic
ADOrs.AddNew
ADOrs!Source = Me.Text9
ADOrs!Type = Me.Text11
ADOrs!Fund = Me.Text13
ADOrs!Account = Me.Text15
ADOrs!Date = Me.Text21
ADOrs.Update
ADOrs.Close
mycon.Close
Me.TreasurerDeposits.Requery
End Sub
field is empty...then a msgbox prompts for the date and the insert should
cancel.
the following msgbox prompts correctly but when I click OK, the record is
created anyway, why is this happening?
Private Sub Command17_Click()
If IsNull(Text21) Then
MsgBox "Enter a Date on Top", vbOKOnly, Date
Cancel = True
Me.Text21.SetFocus
End If
Dim mycon As New ADODB.Connection
Dim ADOrs As New ADODB.Recordset
Set mycon = CurrentProject.Connection
ADOrs.Open "TreasurerDeposits", mycon, adOpenKeyset, adLockOptimistic
ADOrs.AddNew
ADOrs!Source = Me.Text9
ADOrs!Type = Me.Text11
ADOrs!Fund = Me.Text13
ADOrs!Account = Me.Text15
ADOrs!Date = Me.Text21
ADOrs.Update
ADOrs.Close
mycon.Close
Me.TreasurerDeposits.Requery
End Sub