Welcome to SPN

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

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

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. OP
    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. OP
    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
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page