-----Original Message-----
Any button on an Access form is controlled by code (VBA -
Visual Basic for Applications). If you require a button
to do more than one action you need to update the code
behind the button.
For example if you create a button, using the wizard, that
saves a record the chances are Access will create this:
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu,
acSaveRecord, , acMenuVer70
Exit_Command3_Click:
Exit Sub
Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click
End Sub
Don't be offput by all this this. In my example Command3
is just the name of the button.
In the form design view select your button and in the
Events tab of the properies dialog you should have {Event
Procedure] against the On Click property. Select this
property and 3 dots (elipsis) should appear to the right.
Click the elipsis and Access will open the code behind the
button.
After the line of code:
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
enter a newline then then add:
DoCmd.Close
This extra line of code will close your form after the
record has been saved.
With regard to undoing a change add this line of code:
DoCmd.RunCommand acCmdUndo
before the Docmd.Close line of the close button on your
form code.
This subject can start to get involved, so I will leave
you at this pointm however contact me at
(e-mail address removed) for further assistance if
required.
Bish
-----Original Message-----
I've created a Save and Cancel button on my form but they
are not working as they should. I want the save button to
save the data and close the form. I want the Cancel button
to NOT accept the entries and close the form. What do I
need to put in my Expression or do I need to do something
else.
Please help!
Diana Minks
Tech Writer, ALLTEL Communications
678-351-4282
.
.