Results 1 to 4 of 4
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    Function invocation won't compile

    I've just added an optional parameter to the "Highlight" function:

    Given the function coded:
    Code:
    Public Function Highlight(strLBL As String, Optional Init As Boolean = False)
    The compiler claims a syntax error with:



    Code:
    Highlight(sortcolumn,True)
    Where "sortcolumn" is a string variable.

    What am I missing here? (no pun intended)

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    its a function, so it returns somthing,
    either
    x = Highlight(sortcolumn,True)
    or no value to return
    CALL Highlight(sortcolumn,True)

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    That's funny, I almost put a "Call" in front of the function name but didn't because up until I added the optional parameter for years I've coded the invocation as "Highlight(SortColumn)".

    Compiler is happy now.
    Thanks,
    Bill

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Or you can use Highlight sortcolumn,True

    You can't have the parentheses when you don't use it as a function, even though it is declared as one.

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

Similar Threads

  1. Compile Error: Sub/Function not defined
    By TheKillerMonkey in forum Programming
    Replies: 12
    Last Post: 04-18-2016, 01:48 PM
  2. Replies: 10
    Last Post: 03-20-2015, 07:15 PM
  3. Compile Error Sub or function not defined
    By Ray67 in forum Reports
    Replies: 3
    Last Post: 07-02-2012, 04:11 PM
  4. Replies: 6
    Last Post: 11-24-2011, 08:38 PM
  5. Compile error. Sub of function not defined
    By plavookins in forum Reports
    Replies: 7
    Last Post: 04-22-2011, 10:15 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