Results 1 to 4 of 4
  1. #1
    dreamnauta is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2011
    Posts
    16

    Arrow Function - Returning a Value


    Hello Everyone,

    I have a simple logic error here i'm sure, somewhere here. I am trying to return a string from this function. Any help is appreciated!


    Code:
    Function FindExportQuery(Optional numberInput As Integer)
    
    If IsMissing(numberInput) = True Then
    
        If Me.radioGroup.Value = 3 And listBox.ListCount = 0 Then
            strQueryName = "Degree_Completions_No_CIP"
        
        ElseIf Me.radioGroup.Value = 2 And listBox.ListCount = 0 Then
            strQueryName = "Enrollment_Data_No_CIP"
     
        ElseIf Me.radioGroup.Value = 3 And listBox.ListCount > 0 Then
            strQueryName = "Degree_Completion_Results"
          
        ElseIf Me.radioGroup.Value = 2 And listBox.ListCount > 0 Then
            strQueryName = "Enrollment_Results"
        End If
        
    Else
    
        If numberInput = 1 Then
            strQueryName = "Degree_Completions_No_CIP"
    
        ElseIf numberInput = 2 Then
            strQueryName = "Enrollment_Data_No_CIP"
    
        ElseIf numberInput = 3 Then
            strQueryName = "Enrollment_Results"
    
        ElseIf numberInput = 4 Then
            strQueryName = "Degree_Completion_Results"
        End If
    End If
    
    FindExportQuery = strQueryName
    
    End Function

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The return should be specified, like here:

    http://www.baldyweb.com/Function.htm

    but unspecified will be a Variant, so that should still work. How are you calling it?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    What is error message? Have you step debugged? What line fails?

    According to Access Help, IsMissing requires Variant type as input.
    "IsMissing does not work on simple data types (such as Integer or Double) because, unlike Variants, they don't have a provision for a "missing" flag bit."

    This makes sense because declared number variables initialize with 0 value, string variables initialize with empty string, boolean initialize as False. So number and boolean variables would never be missing a value. The empty string will also probably not meet the missing condition.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    dreamnauta is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2011
    Posts
    16
    Ahh k thank you. There are no errors from the function itself, must be the way I called it. Thanks for the information on isMissing() !

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

Similar Threads

  1. Returning PK after append?
    By MikeMairangi in forum Database Design
    Replies: 5
    Last Post: 08-18-2011, 04:28 PM
  2. Having Trouble Returning Array from Function
    By NigelS in forum Programming
    Replies: 8
    Last Post: 08-15-2011, 07:12 AM
  3. Query - Returning ID instead of Value...??
    By Poolio in forum Queries
    Replies: 5
    Last Post: 04-18-2011, 07:10 AM
  4. record set not returning rows
    By lvmoore in forum Forms
    Replies: 3
    Last Post: 09-25-2010, 10:48 AM
  5. Calling a function and returning a value
    By 3dmgirl in forum Programming
    Replies: 0
    Last Post: 04-23-2007, 02:20 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