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

Exit Form but do NOT save record not working 2

Status
Not open for further replies.

PeanutB7

Programmer
Joined
Jun 13, 2005
Messages
56
Location
US
I have tried using the button wizard for Exit Record with no save which uses a macro but the record still is saved. I haved written the DoCmd:

DoCmd.Close acForm, "ProjectInformation",acSaveNo

and it still saved the record. I have been told to include:

IfMe.Dirty then Me.Undo

but I am not sure how to include this within the DoCmd above. I tried but it is coming back as an error. Any help would be greatly appreciated.

Thanks
 
Ok, Here's an example button that performs what you are trying to achieve:

Code:
Private Sub cmdCloseNoSave_Click()
On Error Goto Err_Handle
'If changes have been made, undo them
    If Me.Dirty Then
        
        Me.Undo
    End If

'Following the check for changes, close the form.
    DoCmd.Close acForm, "ProjectInformation"

Err_Exit:
    Exit Sub
Err_Handle:
    Msgbox "Error:" & err & " " & error & " occured!", vbOKOnly + vbCritical, "Error"
    Resume Err_Exit
End Sub

HTH's

------------------------
Hit any User to continue
 
Thank you for the above advise - It worked GREAT!

I have another question on the same form however.

I have include a find record on a form and used the button wizard. Regretfully it is coming up as an error asking find what?

The Action Failed Dialog Box States:

Macro Name - Find Record
Condition - True
Action Name - FindRecord
Argument - ,WholeField, No, All, No, Yes, Yes


Could anyone please tell me the complete argument to include and how to include this.

I have attempted the F1 key but to no avail. I would certainly appreciate your assistance.

Thank you for the time!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top