Macros and Programming


CardboxForumsMacros and Programming > "Macro for 'On Save'"

Macro for 'On Save'

I need to copy and paste a particular field when the file is saved.

Posted By Post


11-Oct-2006 13:43


We are using Now() or Today() to create a unique numbering system. I would like to save this number as text once the file is closed so that next time the file is opened it doesn't create a new number.

I can get the macro for the copy paste no problem but how do I get it to run automatcially when the file is saved so that the other users do not have to worry about doing the cut and paste job.


Charles Welling

11-Oct-2006 15:34

Let's assume that you've called your macro "Save". Edit the native format of your database and go to the Tools menu where you will find the options "Keyboard" and "Toolbar".

By default the "CTRL-s" keys and the "Save" button of the toolbar will only save your record. Nothing more and nothing less.
You can however make "CTRL-s" run a macro by assigning your macro "Save" to these keys.
You can do the same for the "Save" button of the toolbar. Doing this will automatically redirect the menu option "Save record" (feature added in build 4220) to the same macro.

When you do this, users may use "CTRL-s", the button or the menu to save the record, but in all cases the macro "Save" will be run.

Remember that your macro must end with the SaveRecord command or else the record will not be saved.

Tip: you can make your macro check and edit each and every field in the record. It can automatically correct common mistakes. In many cases, it can do this more precisely than standard validation can, and you can present the users with your own messages.


© 2010 Cardbox Software Limited   Home