Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Brilliant! Your site is great...and saving me hours of time at work and making my boss think I am brilliant too! I also picked up on a thread that will potentially save us a lot of money in the future..."

Geography

Where in the world do Tek-Tips members come from?

VBA Newbie Question - canceling data entry

Milin (TechnicalUser)
6 Jan 00 0:13
Forgive me if this is a stupid question - I am new to foraying into the VB side of Access97

I have created a small Rolodex database with one front end form that folks will use. I have set up three "states" of the form, View Only, Edit Mode, and Add a New Record Mode...all within one form. I have these differnt states activated by buttons, and have the fields lock or unlock with the "enabled" property on the buttons. The only part I can't get is that when the user goes into edit or new record mode, writes or deletes stuff, and then I give them a dialogue box that asks if they want to save or cancel, I don't understand how to do a true cancel and not have the new record added anyway, or the editing added anyway. I realize that as soon as someone types or deletes something, it's being instantly done in the source table, so is there some VBA way to undo that?? Like put the changes into some temporary la la land? As an example, here is the code I have for the save/cancel button in edit mode...

Private Sub btnSaveEdit_Click()
On Error GoTo Err_btnSaveEdit_Click
Dim Savechoice

Savechoice = MsgBox("Do you want to save your changes?", vbYesNo, "Save")

If Savechoice = vbYes Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Else
DoCmd.CancelEvent

End If
Exit_btnSaveEdit_Click:
Exit Sub

Err_btnSaveEdit_Click:
MsgBox Err.Description
Resume Exit_btnSaveEdit_Click

End Sub

Please have mercy on my green-ness, o great ones! :-)

DougP (MIS)
6 Jan 00 9:07
Try using Debug.print to see if infact the cancel button is giving the result you expect.
Also put in Stops (Press F9) in the code window and use Ctrl-G to bring up the immediate window.
type ?variablename and press the enter key
you can see any value when tht program is in Halt mode.

hope this helps
elizabeth (IS/IT--Management)
6 Jan 00 10:48
Try using the buttons to alter the "Allow..." properties instead.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close