Calling user-defined function from a select query in Access 2002

B

Brian

I have referenced a user-defined function from a query in
Access. The query is calling the function properly, but I
am not getting the return value, just a NULL value.

Example:

In the query I use:
"Select temp.item_num, FirstTwo(other_text) from temp"

The public FirstTwo function looks like:

Public Function FirstTwo(x) 'where x is a public string
Let x=Left(x,2)
End Function

Any clues as to how I can OR if I can retrieve the value
that FirstTwo is changing? I know the function is working
because I tested with a MsgBox to display x. Remember,
this is only an example of what I am doing and any help
will be appreciated.
 
C

Cheryl Fischer

To return the value of the function to your query, try this:

Public Function FirstTwo(x as String) as String 'where x is a public string
FirstTwo = Left(x,2)
End Function

hth,
 
B

Brian

Thanks, Cheryl! That did the trick.

Brian S. Cook
Freedman Food Services
Houston, Texas
 

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