AfterUpdate Current Record not found

pgruenke

New member
Local time
Today, 03:49
Joined
Jan 26, 2016
Messages
1
2010 Access 32 bit database running on Windows 7 32 bit

The database functions without any problems until I convert it to an .accde or .accdr.

I have a form with the following in its BeforeUpdate event:

Private Sub Form_BeforeUpdate(Cancel As Integer)

On Error GoTo errHandler

Const MESSAGE_TEXT = "You didn't mark the DRAI Offense in B1. Delete the score you entered for B1, check the most serious offense as the DRAI Offense, and re-enter the B1 score."
Dim strCriteria As String

strCriteria = "Chosen = True And ReferralID = " & Me.ReferralID

If Not IsNull(Me.IIA) Then
If DCount("*", "PresentingOffenses", strCriteria) = 0 Then
MsgBox MESSAGE_TEXT, vbExclamation, "Invalid Operation"
Cancel = True
End If
End If
Exit Sub

errHandler:
MsgBox "Error " & Err.Number & ": " & Err.Description & " in " & _
VBE.ActiveCodePane.CodeModule, vbOKOnly, "Error"

End Sub

This is called when I choose a charge(s) on the Charges subform but fail to check the checkbox next to the most serious charge, and then return to the main form to enter a score corresponding to that most significant charge.

Full version database, all works well. On the runtime and .accde the message displays and immediately following I get the attached error. I click on OK and the error message goes away. The box where I enter the score had an "after update" event but I removed it and I continue to get the same error. I don't know what is causing the error, and it doesn't seem to do anything but irritate. How can I get rid of the message box? Thanks in advance.
 

Attachments

  • error.png
    error.png
    11.4 KB · Views: 85
....How can I get rid of the message box?
Difficult to say if we don't have your database, so could you post a stripped down version of it with some sample data, (zip it because you haven't post 10 post yet) + an exact description how to reproduce the error.
Normally True/False = -1/0 so:
Code:
strCriteria = "Chosen = True And ReferralID = " & Me.ReferralID
Should be:
Code:
strCriteria = "Chosen = [B][COLOR=Red]-1[/COLOR][/B] And ReferralID = " & Me.ReferralID
You should comment out the error handling until the code runs okay then it is much easier to find exact codeline in which the error appear!
 
if its working in accdb, should work with accdr/accde. compact your db and try compiling it again.
 

Users who are viewing this thread

Back
Top Bottom