cancel saving record

amoona

Registered User.
Local time
Tomorrow, 00:27
Joined
Jan 18, 2005
Messages
20
Hi,
(this might be easy but i'm just a begginer)

i have a form which has a subform in it where the user has to enter some data in both forms.
i added two buttons on the form one to save and the other to cancel.
my problem is i don't the proper code to cancel the data entered by the user.
i tried this code which i took from delete button wizzard:
Code:
   DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
   DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

but this only deletes the data from the table related to the main form and not the data of the table related to the subform.

thank you,

(note: If anyone could lead me to some good tutorial sites on Access because all the sites i have found have only some basic things.)
 
amoona said:
Code:
   DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
   DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

First of all, remove that code and replace it with:

Code:
DoCmd.RunCommand acCmdDeleteRecord

This is because that code you have from the wizards has been obsolete since Access 97.

To cancel a record you would use, in the relevant form's BeforeUpdate() event, the phrase:

Code:
Cancel = True

Also, over your relationships (assuming they are properly connected and your data properly normalised) ensure that they have Cascade Delete selected.

THere's not that many tutorial sites - most people tend to learn from available resources. In this case:

  • Examples in the Access Help Files;
  • Examples posted in forums such as the Sample Databases forum here;
  • Books, if available;
  • Searching through forum archives;
  • Websites, like this one;
  • Asking questions, no matter how silly or simple you feel they may be
 
thank you very much :)
 

Users who are viewing this thread

Back
Top Bottom