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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error message "save action was canceled" and missing records

Status
Not open for further replies.

at51178

Technical User
Mar 25, 2002
587
US
Hey guys

I created a Quiz in access with three questions for now

I go through each form and at the end when I get all the results back in a form it tells me the question that i wrong and it tells me what my score is when i press exit on the command button I created it closes the form when I go back inside and look at the query and the table I do not see anything in there. not only that

but I added a docmd.save code in the command button but for some reason when someone else is in there I get a message saying save action was cancelled I know why this happens but is there a way around it.

this is the code I use for the command button at the last form when i get all my results


Private Sub cmdexit_Click()
DoCmd.Save
DoCmd.Quit


if you need any further explanation please let me know.

thanks
 
I'm not sure why you put the DoCmd.Save in there unless you're trying to save design changes in an Access object. If you're trying to save the current record you should use:
Code:
RunCommand acCmdSaveRecord

Also, the 'Action was cancelled' message appears quite often in Access if you don't use error handling in your methods. Try trapping the Cancel action like this:

Code:
Sub Whatever()
On Error GoTo ErrHandler

    ' code stuff here...

ExitHere:
    Exit Sub
ErrHandler:
    If Err <> 2501    ' 2501 = Cancelled
        MsgBox Err & &quot; - &quot; & Err.Description
    End If
    Resume ExitHere
End Sub

When the handler detects error 2501 it exits the procedure normally, otherwise it displays the error.

Error 2501 is not really an error it's just a way to detect when a user cancels a report or other action.

Sometimes it makes sense to turn warnings off, such as when running action queries that normally prompt the user for confirmation before making any updates. In that case, use:
Code:
DoCmd.SetWarnings False

Just make sure to turn them back on when you're done:

Code:
DoCmd.SetWarnings True
VBSlammer
redinvader3walking.gif
 
thanks or the advice it actually helped me understand it better.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top