Prob getting value from function

D

dgmoore

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
 
D

dgmoore

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

dgmoore

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top