how to stop acces from saving the record when the

C

Chipcom

Hi

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


Thanks
 
S

SmartbizAustralia

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
 
A

Arvin Meyer [MVP]

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
 
C

Chipcom

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?
 
C

Chipcom

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?
 

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

Top