Error 2115

C

Chuck Sears

I have an unbound text box on a form that is giving an
error 2115, saying that the BeforeUpdate or ValidationRule
for the field is preventing the update. There is no code
at all in the BeforeUpdate event and there are no
validation rules.

Help!!

If RS!ContactDeceased = "yes" Then
chkDeceased = 1
With txtDOD
.Visible = True
.SetFocus
.Locked = False
If Not IsNull(RS!dateofdeath) Then
sDOD = Format(RS!dateofdeath, "mm/dd/yyyy")
error occurs here>>> .Text = sDOD
Else
.Text = "Unknown"
End If
.Locked = True

End With
 
R

Raghu Prakash

Hi Chuck,

Commands Not Available During BeforeUpdate Event
http://support.microsoft.com/default.aspx?scid=kb;en-us;128195
Microsoft Knowledge Base Article - 128195

CAUSE
Microsoft Access cannot perform the specified command because the
BeforeUpdate event procedure is still running. This is true even if the
Cancel parameter is set to True or if a CancelEvent macro attempts to
cancel the action.

These error messages are generated by the following statements in the
BeforeUpdate event procedure:

' Undo the current record. (Microsoft Access 2.0 only)

' NOTE: This behavior no longer occurs in Microsoft Access 7.0 and 97)

DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, 1

' Goto a new record.
DoCmd.GoToRecord , , acNewRec '(Microsoft Access 7.0 and 97)
DoCmd GoToRecord , , A_NEWREC '(Microsoft Access 2.0 )

' Find a record
DoCmd.FindRecord "Smith", , True, acAll, True '(Microsoft Access 7.0 and 97)
DoCmd FindRecord "Smith", , True, A_ALL, True '(Microsoft Access 2.0)

RESOLUTION
Instead of setting the Cancel parameter to True, or using the CancelEvent
action, use a SendKeys statement if that is an option with the command you
are trying to use. The SendKeys statement sends keystrokes to the Microsoft
Access buffer, where they wait until the BeforeUpdate event procedure is
finished.

Please let me know has this helped You...
Thank you...
Raghu...
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

Dirk Goldgar

Chuck Sears said:
I have an unbound text box on a form that is giving an
error 2115, saying that the BeforeUpdate or ValidationRule
for the field is preventing the update. There is no code
at all in the BeforeUpdate event and there are no
validation rules.

Help!!

If RS!ContactDeceased = "yes" Then
chkDeceased = 1
With txtDOD
.Visible = True
.SetFocus
.Locked = False
If Not IsNull(RS!dateofdeath) Then
sDOD = Format(RS!dateofdeath, "mm/dd/yyyy")
error occurs here>>> .Text = sDOD
Else
.Text = "Unknown"
End If
.Locked = True

End With

Chuck -

Where is this code being executed? It's quite likely that you don't
need all of that code to get the effect you want. In particular, you
don't need to SetFocus to the txtDOD control, because you don't actually
need to set its .Text property -- use its .Value property instead.

Try this: Make sure that the Format property of txtDOD (on its property
sheet in design view) is blank, and that its Locked property is True.
Then revise your code as follows:

If RS!ContactDeceased = "yes" Then
chkDeceased = 1
With Me.txtDOD
.Visible = True
If Not IsNull(RS!dateofdeath) Then
.Value = Format(RS!dateofdeath, "mm/dd/yyyy")
Else
.Value = "Unknown"
End If
End With
Else

' ... whatever

End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top