Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to return param.s from a Sub

Status
Not open for further replies.

DonU

MIS
Jan 31, 2002
19
0
0
CA
I have a prob. returning values from a Subroutine in Access 2000. I thought that the default was to pass ByRef which would allow the called routine to change the value which would allow the calling routine to see the new value.

I am coding:

Code:
Option Compare Database
Option Explicit

Private Sub Command0_Click()
   Dim ReturnValue As String
   
   TestReturn (ReturnValue)
End Sub

Sub TestReturn(ByRef ReturnValue)
   ReturnValue = "Hi"
End Sub
but the ReturnValue in the Click routine never gets the new value. I have tried it with and without ByRef, tried diff. var. types, including leaving it as a variant, with no sucess.

Am I doing something wrong, did I misunderstand the help on this, or is there a bug in 2000? I know I could define the above as a Function instead but the case I'm really coding would require several values returned.

Any help greatly appreciated.
 
Either:
TestReturn ReturnValue
Or:
Call TestReturn(ReturnValue)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks,

That works just fine.

Too obvious for my overworked brain I guess.

Don
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top