Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Prob getting value from function

Discussion in 'Information Technology' started by dgmoore@erols.com, Nov 18, 2005.

  1. dgmoore@erols.com

    dgmoore@erols.com
    Expand Collapse
    Guest

    This is an easy one, but not something I work with very much. I need to
    use the value returned by a function in a query, but am encountering an
    error.

    Function GetIDs()

    Dim db As Database
    Dim IDs As Recordset
    Dim strIDs As String
    Set db = CurrentDb()
    Set IDs = db.OpenRecordset("tbl_x")

    ....[loop through table and generate strIDs]...

    GetIDs = strIDs

    Here I get error 'Expected function or variable'.

    I have an (apparently) analogous function that works fine:

    Public PageDate As Date
    Function GetDate()
    If PageDate = "12:00:00 AM" Then
    GetDate = Format(Date, "mm/dd/yy")
    Else
    GetDate = PageDate
    End If

    I'm not seeing where the function that works is different from the one
    that doesn't. Could somebody point out the error of my ways?

    Thanks
    Dave
     
  2. Loading...

    Similar Threads Forum Date
    Sikh News Sikhs Face Problems While Carrying Kirpans In Khyber-Pakhtunkhwa - SikhSiyasat.Net Breaking News Jul 29, 2016
    "Dasam" Granth - A Look At The Core Problems Dasam Granth Oct 21, 2015
    Problems In Life Sikh Sikhi Sikhism Apr 13, 2015
    India Chattisinghpora massacre, fresh probe demanded Breaking News Mar 27, 2014
    1984 Where do Things Stand with SIT toward Probe into 1984 genocide? History of Sikhism Feb 11, 2014

  3. dgmoore@erols.com

    dgmoore@erols.com
    Expand Collapse
    Guest

    Duh - I was trying to execute GetIDs as a Sub rather than a function.
    It works fine now. Amazing how dumb you (I) can be...
     
  4. dgmoore@erols.com

    dgmoore@erols.com
    Expand Collapse
    Guest

    OK - I'm back. My function returns the correct string, but it doesn't
    work in my query:

    select .... from .... where ... In(GetDepsID())));

    If I put the string directly in the query it works correctly, but with
    the function it returns no records.

    Any suggestions?

    Thanks
    Dave
     

Share This Page