T
Troy Street
Hello,
I've created a form that displays data from one table based on the value of
another table. I've placed a check box on the form, so when the user checks
it, it updates a textbox (A) with the current date, then performs a dateadd
function based on
TextBox A and an interger value in TextBox B, putting the result in Textbox
C.
My problem occurs when trying to change the value of textbox A. I get an
error to the effect of "A macro or validation rule is preventing the field
from being updated." I have no validation rule set in the underlying table
or properties. I am also getting messages that Access cannot move the focus
to the second or third control.
I am really at a loss, because in several other areas of the same database,
I've successfully used similar code to accomplish similar results. I've
compared property settings of forms and controls and cannot find what I may
be overlooking. The database has been updated through the years from Access
95, 98, and 2000. Another change has been the operating system being used to
develop the forms (now on Windows 2000 OS) Might these have anything to do
with the problem? Any Ideas are welcome! Thanks in advance.
Here's the code:
Private Sub chkComplete_Click()
Dim x As String, y As String, z As Integer
If chkComplete.Value = 0 Then
Exit Sub
ElseIf chkComplete.Value = -1 Then
x = Format(Date, "mmm-yy")
txtLastPerformed.SetFocus
txtLastPerformed.Text = x '---Error occurs here
txtMaintenanceInterval.SetFocus '---Access can't setfocus here
z = Val(txtMaintenanceInterval.Text)
txtNextDue.SetFocus
y = Format(DateAdd("m", z, x), "mmm-yy")
txtNextDue.Text = y
Exit Sub
End If
End Sub
I've created a form that displays data from one table based on the value of
another table. I've placed a check box on the form, so when the user checks
it, it updates a textbox (A) with the current date, then performs a dateadd
function based on
TextBox A and an interger value in TextBox B, putting the result in Textbox
C.
My problem occurs when trying to change the value of textbox A. I get an
error to the effect of "A macro or validation rule is preventing the field
from being updated." I have no validation rule set in the underlying table
or properties. I am also getting messages that Access cannot move the focus
to the second or third control.
I am really at a loss, because in several other areas of the same database,
I've successfully used similar code to accomplish similar results. I've
compared property settings of forms and controls and cannot find what I may
be overlooking. The database has been updated through the years from Access
95, 98, and 2000. Another change has been the operating system being used to
develop the forms (now on Windows 2000 OS) Might these have anything to do
with the problem? Any Ideas are welcome! Thanks in advance.
Here's the code:
Private Sub chkComplete_Click()
Dim x As String, y As String, z As Integer
If chkComplete.Value = 0 Then
Exit Sub
ElseIf chkComplete.Value = -1 Then
x = Format(Date, "mmm-yy")
txtLastPerformed.SetFocus
txtLastPerformed.Text = x '---Error occurs here
txtMaintenanceInterval.SetFocus '---Access can't setfocus here
z = Val(txtMaintenanceInterval.Text)
txtNextDue.SetFocus
y = Format(DateAdd("m", z, x), "mmm-yy")
txtNextDue.Text = y
Exit Sub
End If
End Sub