Results 1 to 4 of 4
  1. #1
    TimMoffy is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Posts
    29

    Module Error in Macro

    I have created a module as below, which when I use Run in the VBA window does exactly what i want it to.


    However when i then run this from a macro i constantly get a message box saying that
    "the expression you entered has a function name that the [database] cannot find"

    In the macro i have used Run Code with ChangeDataType() as the function name.
    The module is called modChangeDataType
    Public Sub ChangeDataType()
    Dim dbase As DAO.Database
    Set dbase = CurrentDb
    dbase.Execute ("ALTER TABLE tblReopenDates ALTER COLUMN [ReopenDate] date;")
    End Sub

    I'm stumped as I have tried every permutation of naming for the function i can think of, but still it sends an error every time.
    Any ideas?
    Thanks

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I believe you can only call a function from RunCode. Change "Sub" to "Function" in both places and try it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    TimMoffy is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Posts
    29
    Thanks Pbaldy - its so simple when you know how.

    Works perfectly - Thanks

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problemo!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Converting Excel Macro into Access Module
    By diddyville in forum Modules
    Replies: 1
    Last Post: 03-28-2011, 07:02 PM
  2. Module to be run by macro to validate
    By GraemeG in forum Modules
    Replies: 4
    Last Post: 02-26-2011, 06:26 AM
  3. Error in Module
    By Alex Motilal in forum Modules
    Replies: 9
    Last Post: 01-21-2011, 09:21 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

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