Results 1 to 6 of 6
  1. #1
    william barker is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2016
    Posts
    4

    How to run this module from a macro

    the following code creates the file as expected when run within the module.

    how can this be inserted as a step within a macro, I tried RUNCODE to no avail.

    Public Function NRP_Extract()


    Dim Cmonth As String
    Dim Cday As String
    Dim DATENOW As String
    Dim FileName As String

    If Month(Now()) < 10 Then
    Cmonth = "0" & Month(Now())
    Else
    Cmonth = Month(Now())
    End If

    If Day(Now()) < 10 Then
    Cday = "0" & Day(Now())
    Else
    Cday = Day(Now())
    End If


    DATENOW = Year(Now()) & Cmonth & Cday
    FileName = "L:\West Chester\Supply Chain Management" & DATENOW & "NRP_Master_Data_Extract.xlsx"




    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "q_NRP_Master_Data_Extract", FileName, True, ""
    End Function

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,523
    Runcode is correct.
    runcode nrp_extract()

    you must have the parens. If it still fails,then put a breakpoint on the 1st statement in the code.
    run the macro.
    then step thru the code (F8) to see where it fails.

  3. #3
    william barker is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2016
    Posts
    4
    Got the following error when trying to run the macro:

    The expression you entered has a function name that microsoft access cant find.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,784
    Where is the code? AFAIK, it has to be in a standard module, not a form module. Not 100% sure because I don't use macros but I read that somewhere. The function name also cannot be the same as the module.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    william barker is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2016
    Posts
    4
    would you have time for a webex in the next few days? I dont have much experience with what i am doing....

    i just added the runcode to a macro and can not get it to execute...

    send me your email address if you can

  6. #6
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,784
    Who, me?
    If you are not using features not supported by 2007 I can take a look at your db. Compact, then zip a copy of it and post it here. I'm unfamiliar with remote technologies that people often refer to in this forum and don't wish to expose my computer to remote systems.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Query..Module..Macro....HELP!!!
    By RIRinkRat in forum Modules
    Replies: 1
    Last Post: 10-17-2012, 07:34 PM
  2. Module Error in Macro
    By TimMoffy in forum Modules
    Replies: 3
    Last Post: 06-20-2012, 09:52 AM
  3. Module to be run by macro to validate
    By GraemeG in forum Modules
    Replies: 4
    Last Post: 02-26-2011, 06:26 AM
  4. Creating Macro from Module
    By Harley Guy in forum Modules
    Replies: 1
    Last Post: 11-08-2010, 07:44 AM
  5. Running module from Macro
    By Harley Guy in forum Modules
    Replies: 6
    Last Post: 10-27-2010, 11:05 AM

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