Depending on the type of data you're working with, you can automate the importing, exporting, and linking of data by carrying out the TransferDatabase, TransferSpreadsheet, or TransferText actions in a macro or Microsoft Visual Basic procedure.
Use a macro
How?
How?
Another database Click TransferDatabase in the action list of a blank action row.
A spreadsheet file Click TransferSpreadsheet in the action list of a blank action row.
A text file Click TransferText in the action list of a blank action row.
How?
To run a macro directly, do one of the following:
Use a Visual Basic procedure
How?
Function IsLoaded (strFormName As String) As Boolean
How?
Microsoft Access defines a special object, DoCmd, that you use to carry out macro actions in Microsoft Visual Basic procedures. You carry out an action by adding a method of the DoCmd object to your procedure. Most actions have a corresponding DoCmd method.
DoCmd.method [arguments]
Method is the name of a method. Arguments are the method arguments, if there are any.
For example, to create a procedure that carries out the OpenForm action, add the OpenForm method of the DoCmd object to the procedure. The following method is equivalent to the OpenForm action; it opens the Add Products form:
DoCmd.OpenForm "Add Products"
A few actions don't have corresponding DoCmd methods, although some have equivalent Visual Basic statements or functions.
Macro actions that don't have a corresponding DoCmd event
Action | Microsoft Visual Basic equivalent |
---|---|
AddMenu | No equivalent |
MsgBox | MsgBox function |
RunApp | Shell function |
RunCode | Procedure call (Call statement) |
SendKeys | SendKeys statement |
SetValue | Assignment statement (Let statement) |
StopAllMacros | Stop or End statements |
StopMacro | Exit Sub or Exit Function statements |