Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 12th, 2004, 06:19 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 137
Thanks: 0
Thanked 0 Times in 0 Posts
Default Update problem in MS Access 2000


I have created an input form that uses a command button as a cancel button. Presently on pressing the button it relocks the form and the form becomes a read only form again. My problem is that although users are able to cancel say an Add event using this button any changes made are still recorded.

Is there such code I could add to this to inform access not to save any changes made by the user.

My code looks like this:-

Private Sub btnCancel_Click()

    Me.Staff_Forenametxtbox.Locked = True ' Locked staff forname text box
    Me.Staff_Surnametxtbox.Locked = True ' Locked staff surname text box
    Me.Staff_Servicetxtbox.Locked = True ' Locked service text box
    Me.StaffCheckBox.Locked = True ' Locked Staff checkbox
    Me.VolunteerChexkbox.Locked = True ' Locked Volunteer checkbox
    Me.ACTIVITIES_SUBFORM_FORALL.Locked = True ' Locked users from making amendments to Activity records
    Me.btnSaveRec.Enabled = False ' Disable save button
    Me.btnDelete.Enabled = False ' Disable delete button
    Me.btnAdd.Enabled = True ' Enable add button
    Me.PreRecbtn.Enabled = True ' Enable previous button
    Me.nextBtn.Enabled = True ' Enable next rec button
    Me.Combo89.Enabled = True ' Enable dropdown surname search
    Me.status_bar.Caption = "CURRENT RECORD LOCKED" ' Change record status text
    Me.unlockBtn.Enabled = True ' Enable unlock button
    Me.nextBtn.SetFocus
    Me.btnCancel.Enabled = False ' Disable cancel button
    DoCmd.GoToRecord , , acFirst ' Return to first record in database

End Sub



Gaz
__________________
Gaz
 
Old March 12th, 2004, 07:09 PM
Authorized User
 
Join Date: Feb 2004
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Default

A couple of ideas (assuming bound form). After the update of the record it is too late to cancel. The best place to ask whether you want changes to be written to the database is in the Before_Update event of the form. When this event fires is the time to say yea or nay. If you place a msgbox question, "Accept changes" and set Cancel = True, the data will not be written. Something like a me.Undo or an undo on each control should make the controls revert.

Ciao
Jürgen Welz
Edmonton AB Canada
[email protected]





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem VB.NET 2005 - update data in Ms Access Netuser Pro Visual Basic 2005 0 August 1st, 2008 01:34 PM
Emailing From MS Access 2000 baNTON Access 5 October 13th, 2007 09:58 AM
Database migration MS Access 2003 to MS SQL 2000 ayazhoda SQL Server 2000 3 April 23rd, 2007 11:38 AM
MS Access 2000 kvidy Access 12 June 10th, 2005 10:36 AM
MS Access 2000 Replication ppenn Access 0 February 3rd, 2005 04:27 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.