Error on field beforeUpdate property

dealwi8me

Registered User.
Local time
Tomorrow, 00:45
Joined
Jan 5, 2005
Messages
187
I have the following code as a property to a field(beforeUpdate)

Code:
Private Sub ID_BeforeUpdate(Cancel As Integer)
    Dim strSQL      As String
    Dim rs          As DAO.Recordset
    
    strSQL = "SELECT * FROM RETIREMENT " & _
                "WHERE [ID] = " & Me.ID & ""
                
    Set rs = CurrentDb.OpenRecordset(strSQL)
    
    If Not (rs.EOF) Then
       MsgBox ("Cannot insert record.")
       Me.ID.Value = Null
    End If
    
End Sub

After i get the the message box and i click ok i want to set the id value to null but i get the following error "The macro or function se to BeforeUpdate or validationRule property for this field is preventing Microsoft Office Access from saving tha data in the field."

Any suggestions?

Thank you in advance!
 
Check that ID is allowed a value of NULL. If your Form is bound to a table or Query this would stop the action.
 
ID is allowed a value of null.
The form is bound to table APPLICATION where ID is a member of APPLICATION.
 
I found the error.I should had the code at afterUpdate property instead of beforeUpdate.

Thanks for trying to help me:)
 

Users who are viewing this thread

Back
Top Bottom