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

  • Thread starter Thread starter Brian
  • Start date Start date
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.
 
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,
 
Thanks, Cheryl! That did the trick.

Brian S. Cook
Freedman Food Services
Houston, Texas
 
Back
Top