Returning a value via function (1 Viewer)

croftpw

New member
Local time
Yesterday, 20:46
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.
 

Access_guy49

Registered User.
Local time
Yesterday, 23:46
Joined
Sep 7, 2007
Messages
462
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
 

DJkarl

Registered User.
Local time
Yesterday, 22:46
Joined
Mar 16, 2007
Messages
1,028
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

Top Bottom