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

    Expand Collapse

    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

    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")
    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?

  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 Aug 17, 2016
    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. OP

    Expand Collapse

    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. OP

    Expand Collapse

    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?

Since you're here... we have a small favor to ask...     Become a Supporter      ::     Make a Contribution     

Share This Page