Returning a value via function

croftpw

New member
Local time
Today, 03:56
Joined
Aug 3, 2011
Messages
3
I'm using MS Access 2007 and having difficulty with VBA returning a value from a function. Here's my code, in a module:

Option Compare Database
Global CriteriaStr As String

Function Get_Criteria() As String
Return CriteriaStr
End Function

---
I get a compile error: Expected: end of statement
And it's indicating something is wrong with the "Return" line. What gives? Thanks for helping the newb.
 
Return is a reserved word for returning to a tag when code is interupted.
If you are trying to set the variable to equal the function

criteriastr = get_criteria
 
I'm using MS Access 2007 and having difficulty with VBA returning a value from a function. Here's my code, in a module:

Option Compare Database
Global CriteriaStr As String

Function Get_Criteria() As String
Return CriteriaStr
End Function

---
I get a compile error: Expected: end of statement
And it's indicating something is wrong with the "Return" line. What gives? Thanks for helping the newb.

VBA doesn't support the return command, use
Code:
Get_Criteria  =CriteriaStr
 

Users who are viewing this thread

Back
Top Bottom