Reset form and find record

  • Follow



If user enters an InmateId value and a ClassDate (a unique index) that 
already exits in the table, I want to undo what the user punched in and go 
find the record they tried to duplicate. A button click is called that fires 
two SendKeys "{ESC}", which undoes everything on the form, but I still get a 
runtime error at Me.Bookmark = rs.Bookmark: "The macro or function set to 
the BeforeUpdate or ValidationRule property for this field is preventing db1 
from saving the data in the field." Why is it trying to save anything? I've 
undone all the fields, like it's a new record. Shouldn't it now go to the 
record specified in rs.FindFirst "InmateId = '" & strInmateID & "'"? How can 
I get it to do this? Many thanks, Ripper



Private Sub Form_Error(DataErr As Integer, Response As Integer)

Dim strInmateID As String

Const conErrDuplicateKey = 3022

Select Case DataErr

    Case conErrDuplicateKey

        MsgBox "This record already exists.  ", vbExclamation, "Data Error"

        strInmateID = Me.InmateID

        btnUndo_Click

        Response = acDataErrContinue

        Dim rs As DAO.Recordset

        Set rs = Me.RecordsetClone

        rs.FindFirst "InmateId = '" & strInmateID & "'"

        If rs.NoMatch Then

            MsgBox "No entry found.", vbInformation, "Data Not Found"

        ElseIf Not rs.EOF Then

            Me.Bookmark = rs.Bookmark

        End If

End Select

End Sub





0
Reply RipperT 9/30/2007 3:20:13 PM

Use Me.Undo instead of Sendkeys

Pieter

"RipperT" <rippert@nOsPaM.net> wrote in message 
news:uMqVnV3AIHA.4712@TK2MSFTNGP04.phx.gbl...
>
>
> If user enters an InmateId value and a ClassDate (a unique index) that 
> already exits in the table, I want to undo what the user punched in and go 
> find the record they tried to duplicate. A button click is called that 
> fires two SendKeys "{ESC}", which undoes everything on the form, but I 
> still get a runtime error at Me.Bookmark = rs.Bookmark: "The macro or 
> function set to the BeforeUpdate or ValidationRule property for this field 
> is preventing db1 from saving the data in the field." Why is it trying to 
> save anything? I've undone all the fields, like it's a new record. 
> Shouldn't it now go to the record specified in rs.FindFirst "InmateId = '" 
> & strInmateID & "'"? How can I get it to do this? Many thanks, Ripper
>
>
>
> Private Sub Form_Error(DataErr As Integer, Response As Integer)
>
> Dim strInmateID As String
>
> Const conErrDuplicateKey = 3022
>
> Select Case DataErr
>
>    Case conErrDuplicateKey
>
>        MsgBox "This record already exists.  ", vbExclamation, "Data Error"
>
>        strInmateID = Me.InmateID
>
>        btnUndo_Click
>
>        Response = acDataErrContinue
>
>        Dim rs As DAO.Recordset
>
>        Set rs = Me.RecordsetClone
>
>        rs.FindFirst "InmateId = '" & strInmateID & "'"
>
>        If rs.NoMatch Then
>
>            MsgBox "No entry found.", vbInformation, "Data Not Found"
>
>        ElseIf Not rs.EOF Then
>
>            Me.Bookmark = rs.Bookmark
>
>        End If
>
> End Select
>
> End Sub
>
>
>
>
> 


0
Reply Pieter 9/30/2007 4:55:39 PM


1 Replies
384 Views

(page loaded in 0.032 seconds)


Reply: