how to stop acces from saving the record when the

  • Thread starter Thread starter Chipcom
  • Start date Start date
C

Chipcom

Hi

I need to know how to stop acces from saving the record when the
subform query is on focus?


Thanks
 
You need to use undo.

If the same form, then use me.undo

Otherwise reference the other form before update and run your check to
undo.....

Tom Bizannes
Microsoft Access Development
Sydney,Australia
 
Can You please show VBA example code for this or give me a link of
example for this code?

Sure, put this code in the form's Before Update event:

On Error GoTo Error_Handler
Dim db As DAO.Database
Dim rst As DAO.Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("tblWhatever", dbOpenDynaset)

With rst
.AddNew
!WhateverID = Me.txtWhateverID
!FirstName = Me.txtFName
!LastName = Me.txtLName
.Update
End With

Exit_Here:
rst.Close
Set rst = Nothing
Set db = Nothing

Error_Handler:
MsgBox Err.Number
Resume Exit_Here
 
Sure, put this code in the form's Before Update event:

On Error GoTo Error_Handler
Dim db As DAO.Database
Dim rst As DAO.Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("tblWhatever", dbOpenDynaset)

With rst
.AddNew
!WhateverID = Me.txtWhateverID
!FirstName = Me.txtFName
!LastName = Me.txtLName
.Update
End With

Exit_Here:
rst.Close
Set rst = Nothing
Set db = Nothing

Error_Handler:
MsgBox Err.Number
Resume Exit_Here


Hi

I tried the code But I getting:
Error 0
Error 20
Error 91

What I do wrong?
 
You need to use undo.

If the same form, then use me.undo

Otherwise reference the other form before update and run your check to
undo.....

Tom Bizannes
Microsoft Access Development
Sydney,Australia

Hi

I am getting error 2105 is this related to the me.undo ?
Ifso where to put the line in code?
 
Back
Top