Results 1 to 3 of 3
  1. #1
    pritesharyan is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Location
    India
    Posts
    32

    How to run Data macro using VBA Code.

    I try to run Data macro using VBA Code.


    below image shows my question.
    Please guide me.
    Click image for larger version. 

Name:	data macro vba code.png 
Views:	18 
Size:	47.3 KB 
ID:	21039

    Code:
    Private Sub cmdRunDataMacro_Click()
       DoCmd.SetParameter "prmMetalID", Me.cmbMetal
       DoCmd.RunDataMacro "Metal.GetMetalParameter"
       DoCmd.SetProperty txtTestMetal, acPropertyValue, [ReturnVars]![retPrice]
    End Sub

  2. #2
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    I'm not to familiar with this.

    However, you may want to try using Access's built in feature, "Convert Form's Macros to Visual Basic."

    This will remove any user error when creating the macro in vba.

  3. #3
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    2nd line where you run macro looks funny.
    I don't believe that is correct vb syntax/format.
    try
    Code:
    DoCmd.RunMacro "MacroName", 1
    Fill in your macro's name where it says. The 1 means it only runs once which I assume is what you want. If you want it to run more than once just change that number.

    More info: https://msdn.microsoft.com/en-us/lib.../ff192075.aspx

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Help with access code (macro?) please
    By visidro in forum Programming
    Replies: 10
    Last Post: 03-15-2013, 05:56 PM
  2. VBA code or Access Macro
    By CSGabriel in forum Access
    Replies: 1
    Last Post: 07-27-2012, 09:08 AM
  3. VBA code/Macro help please.
    By Davidyam in forum Access
    Replies: 1
    Last Post: 02-26-2012, 09:59 PM
  4. Question about some code in a macro
    By AudiA4_20T in forum Programming
    Replies: 2
    Last Post: 07-11-2011, 08:16 AM
  5. how to create a macro or code to...
    By Eaglezinha in forum Access
    Replies: 1
    Last Post: 10-20-2008, 04:01 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums