L
Lorraine
I am wanting to check if the CompDate field is null or not. If it has a date
then I want the txtPlannedAct field to be checked for the "Stand Exam" value.
If both exist then the Water_Quality checkbox should auto fill. If a
CompDate is entered then the chkCompleted checkbox should auto fill. If the
CompDate field is empty then both checkboxes should be unchecked.
This is all working fine. But I also want the focus to go to the
txtComments field and the txtComments field to auto fill with "water quality
ok" if a CompDate is entered and the txtPlannedAct field value is "Stand
Exam."
After the txtComments field auto fills with "water quality ok" I get a
run-time error 2115 "The macro or function set to the BeforeUpdate or
ValidationRule property for this field is preventing Microsoft Access from
saving the data in the field" and yet the data does save. Do I just need to
add some error capturing to my code? If so, how? I'm not too familiar with
error capturing code.
Private Sub txtCompDate_AfterUpdate()
If Me.CompDate.Value <> IsNull(CompDate.Value) Then
If Me.txtPlannedAct.Value = "Stand Exam" Then
Me.Water_Quality.Value = -1
End If
Me.chkCompleted.Value = -1
Me.txtComments.SetFocus
Me.txtComments.Text = "water quality ok" 'GET A RUN TIME ERROR HERE!
Else
Me.chkCompleted.Value = 0
Me.Water_Quality.Value = 0
Me.Inactive.SetFocus
End If
End Sub
then I want the txtPlannedAct field to be checked for the "Stand Exam" value.
If both exist then the Water_Quality checkbox should auto fill. If a
CompDate is entered then the chkCompleted checkbox should auto fill. If the
CompDate field is empty then both checkboxes should be unchecked.
This is all working fine. But I also want the focus to go to the
txtComments field and the txtComments field to auto fill with "water quality
ok" if a CompDate is entered and the txtPlannedAct field value is "Stand
Exam."
After the txtComments field auto fills with "water quality ok" I get a
run-time error 2115 "The macro or function set to the BeforeUpdate or
ValidationRule property for this field is preventing Microsoft Access from
saving the data in the field" and yet the data does save. Do I just need to
add some error capturing to my code? If so, how? I'm not too familiar with
error capturing code.
Private Sub txtCompDate_AfterUpdate()
If Me.CompDate.Value <> IsNull(CompDate.Value) Then
If Me.txtPlannedAct.Value = "Stand Exam" Then
Me.Water_Quality.Value = -1
End If
Me.chkCompleted.Value = -1
Me.txtComments.SetFocus
Me.txtComments.Text = "water quality ok" 'GET A RUN TIME ERROR HERE!
Else
Me.chkCompleted.Value = 0
Me.Water_Quality.Value = 0
Me.Inactive.SetFocus
End If
End Sub