Save a database object programmatically

Microsoft Office Access 2003

  1. To create a macro, click Macros Button image under Objects, and then click the New button on the Database window toolbar.
  2. In a blank action row, click Save in the action list, and then set the Object Type argument to the type of the object you want to save and the Object Name argument to the name of the object.
  3. Click Save Button image to save the macro.
  4. To test, select the macro and click Run Button image on the toolbar.
  5. The macro is now ready for use by setting the property of another object.

For example, to save a form by clicking a command button on the form, set the button's OnClick property to the name of the macro.

ShowSave a database object by using an event procedure

  1. To open the event procedure for the appropriate event, open the form in Design view.
  2. Display the property sheet for the control you will use to trigger the event and then click the Event tab.
  3. Click the property for the event that you want to trigger the procedure.

For example, to respond to a mouse click on a command button, open the button's OnClick event procedure.

  1. Click Build Button image next to the property box to display the Choose Builder dialog box.
  2. Double-click Code Builder to display the event procedure window.
  3. Use the Save method to carry out the Save action in the procedure, setting the objecttype argument to the type of the object you want to save and the objectname argument to the name of the object.
  4. To test, run the procedure by opening the form in Form view and performing the event that triggers the Save action.

    For example, if the procedure is located in the OnClick event procedure for a command button, click the command button to save the object.