Results 1 to 6 of 6
  1. #1
    boywonder is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Dec 2010
    Location
    Memphis, TN
    Posts
    60

    Using RunCode Macro

    I wrote a Sub Procedure and tried to use it in the RunCode macro, but the description of the RunCode states you have plae the Sub in a Function. I tried that and it did not work. Does anyone know about this?

  2. #2
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,053
    Don't place the sub within a function change the sub to a function. Give the Function a type of Boolean
    Change
    Public Sub Yoursub()
    to
    Public function YourSub() As Boolean

    use this at the end

    Yoursub = True
    End Function

  3. #3
    boywonder is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Dec 2010
    Location
    Memphis, TN
    Posts
    60
    When I enter OutStandingMember() in the RunCode area I get the following error:

    "The expression you entered has a function name that MS Office Access can't find."

    Below is the top portion of the code from the Module object OutStandingMember I'm using:


    Option Compare Database
    Public Function OutStandingMember() As Boolean
    On Error GoTo OutstandingMember_Error
    Dim ws As Workspace
    Dim db As Database
    Dim rsMemberStatus As Recordset
    Dim rsTemp2 As Recordset
    Dim g As String
    Dim j As Integer
    Dim s As Integer
    Set ws = DBEngine.Workspaces(0)
    Set db = CurrentDb

  4. #4
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,053
    Under the Option Compare put in Option Explicit. This requires you to define all of your variables makes it easier to debug.

    If you do a compile to you get an error message?

    Also I use ADO so I'm not sure about this but I believe that it should be Set db = ws.currentdb

  5. #5
    boywonder is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Dec 2010
    Location
    Memphis, TN
    Posts
    60
    I just converted all of the macros to vb code. It's working now.

  6. #6
    Darwood is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2014
    Posts
    1
    You need to put parenthesis/brackets after the function name in the macro.
    eg MyFunc()

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

Similar Threads

  1. Macro
    By robertjleach in forum Programming
    Replies: 13
    Last Post: 10-30-2011, 05:00 PM
  2. Help With Macro's
    By GDubbs780 in forum Programming
    Replies: 1
    Last Post: 02-25-2011, 11:43 AM
  3. Replies: 0
    Last Post: 01-12-2011, 12:43 PM
  4. Need help with macro
    By abc123 in forum Programming
    Replies: 6
    Last Post: 06-13-2010, 12:34 AM
  5. RunCode in macro not working
    By LilMissAttack in forum Access
    Replies: 0
    Last Post: 05-27-2010, 05: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 - Senior Forums