Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cancel update on bound form access97

Status
Not open for further replies.

DannyTmoov2

IS-IT--Management
Jan 7, 2003
49
GB
I have inherited an access 97 database which has loads of bound form objects. I need to catch the update record event and prompt to offer save or cancel. How do i cancel the update when in the Form_BeforeUpdate method?

Any help much appreciated
 
thanks for the quick response snerting, unfortunately i'm getting an object required error. I have literally just added Set Cancel = True to the Form_BeforeUpdate function, anything else i should be doing?
 
The Set instruction is for object instantiation only.
The correct syntax is:
Cancel = True

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Sorry, I was a bit quick there. The reply was meant like "Set 'Cancel = True' to cancel the event. That 'Set' is a syntax word in VBA was unfortunate in this case ;)

However, as PHV says:
Cancel = True
 
thanks, whilst we're on the subject how would i am trying to achieve the following:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim myMsg As Integer

myMsg = MsgBox("The record has been changed, do you wish to save changes?", vbYesNoCancel, "Save Changes")

Select Case myMsg
Case 6
' do nothing, continue to save

Case 7
' dont update but continue to change record

Case 2
' dont update, dont change
Cancel = True
End Select

End Sub

How can i achieve the 2nd option? Many Thanks
 
If you want to revert your changes to the form, do a

'myForm.Undo'

I would guess you need something like:

Select Case myMsg
Case vbNo
' dont update but continue to change record
Cancel = True
Case vbCancel
' dont update, dont change
Me.Undo
Cancel = True
End Select
 
For future reference if anyone is after the same thing:

Select Case myMsg
Case vbNo
' dont update table and move record
Me.Undo
Case vbCancel
' dont update and dont change table (new values remain)
Cancel = True
End Select


Cheers for your help guys!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top