?
Solved

DoCmd.RunCommand (acCmdUndo)

Posted on 2005-05-11
9
Medium Priority
?
982 Views
Last Modified: 2008-01-09
Hi All

Have a VBQuestion Yes/No called from the code below. I am trying to get Access to remove the TapeID (not primary key) from the record if the user selects no from the VB box, nothing is happening, tried many times with/out the brackets. any answers?


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Private Sub TapeID_BeforeUpdate(Cancel As Integer)

Dim x As Variant

   x = DLookup("[TapeID]", "Tapes", "[TapeID]= " & _
          [Forms]![FrmAddProject]![FrmAddProjectTapesSubform]![TapeID])
         
   On Error GoTo TapeID_Err

   If Not IsNull(x) Then
     
      MsgBox "That Tape already in this database. Continue?. Click Yes to continue, No to stop", vbYesNo, "Duplicate Tape?"
   
   If Response = vbNo Then
   
    DoCmd.RunCommand (acCmdUndo)
     
   End If
   
     
TapeID_Exit:

   Exit Sub

TapeID_Err:

   MsgBox Error$
   
   Resume TapeID_Exit
   
   End If
   
   End Sub

0
Comment
Question by:PeterGHill
  • 4
  • 3
  • 2
9 Comments
 
LVL 15

Accepted Solution

by:
Colosseo earned 2000 total points
ID: 13976981
Hi the problem here is that response isnt set to anything

try this

      Response = MsgBox("That Tape already in this database. Continue?. Click Yes to continue, No to stop", vbYesNo, "Duplicate Tape?")
   
   If Response = vbNo Then
   
    DoCmd.RunCommand (acCmdUndo)
     
   End If

or you can also use

If MsgBox("That Tape already in this database. Continue?. Click Yes to continue, No to stop", vbYesNo, "Duplicate Tape?") = vbNo Then
   
    DoCmd.RunCommand (acCmdUndo)
     
   End If

HTH

Scott
0
 
LVL 12

Expert Comment

by:Sayedaziz
ID: 13977029
I think u need to put

Response = MsgBox(MsgBox "That Tape already in this database. Continue?. Click Yes to continue, No to stop", vbYesNo, "Duplicate Tape?")

Then u would be able to check the Response .... whether it is vbYes Or vbNo.

Aziz
0
 
LVL 12

Expert Comment

by:Sayedaziz
ID: 13977035
sorry late to post
Colosseo post is the first to receive attention.
Aziz
0
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 

Author Comment

by:PeterGHill
ID: 13977178
Scott

Mmm

Back to front eh - see where you are comming from but I am getting a msg box

'the command or action Undo isnt available now -

Any reason for this....
0
 
LVL 15

Expert Comment

by:Colosseo
ID: 13977253
Hi there going from what you have said I am guessing that at that stage you havent actually updated the database and therefore there is no action to undo

try changing

  DoCmd.RunCommand (acCmdUndo)

to Cancel = True

this should stop the update occuring

Cheers

Scott
0
 

Author Comment

by:PeterGHill
ID: 13977399

Dear All

still not clearing the field, and after I click no the numbers are still there and hence no atter where i click on the form the first message box re duplicates is in a loop. The field only clears on escape or undo current field/record.

Is this some reason because the data hasnt been written and if I add it to the after update ect....

I would really like the inputted numbers to be deleted
0
 

Author Comment

by:PeterGHill
ID: 13977426
Scott,

Seem to have answered my last question, and due to the fact that you were spot on, its just that I had it in the before update not after update points go to:


MR Frosty!
0
 
LVL 15

Expert Comment

by:Colosseo
ID: 13977454
Cool glad your working :)

Cheers

Scott
0
 

Author Comment

by:PeterGHill
ID: 13977552
got another extension on this question - new thread

ppt
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question