DoCmd.RunDataMacro method (Access)
Use the RunDataMacro method to run a named data macro from Visual Basic.
Syntax
expression.RunDataMacro (MacroName)
expression A variable that represents a DoCmd object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
MacroName | Required | Variant | Name of the saved macro. The name must include the name of the table to which the data macro is attached (for example, Comments.AddComment). |
Remarks
Use the RunDataMacro method to reuse a named data macro in Visual Basic code.
If the data macro requires parameters, you must first create them by using the SetParameter method prior to calling the RunDataMacro method. Each call to SetParameter creates a single named parameter.
Example
The following code example creates two parameters for use by the AddComment data macro. The two parameters are named prmComment and prmRelatedID, respectively. The value of the txtComment text box is stored in the prmComment parameter. The value of the txtId text box is stored in the prmRelatedID parameter. The "Comments.AddComment" data macro is then run.
Private Sub cmdAddComment_Click()
DoCmd.SetParameter "prmComment", Me.txtComment
DoCmd.SetParameter "prmRelatedID", Me.txtId
DoCmd.RunDataMacro "Comments.AddComment"
End Sub
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기