Return value in Function

skiphooper

Registered User.
Local time
Today, 01:02
Joined
Nov 29, 2000
Messages
76
Hi EveryOne,

I am using A2k.

I have written a function called x_lookup, to return certain fields in a table or query based on user input.
Lets say one of the variables passed to the function is rtn_fld as string
This variable containes the field name of what the user wants passed back.

My recordset is called rstInpt.
The user passed "NP3" as rtn_fld.
When I return the field with statement:

x_lookup = rstInpt!

How do I get the return statement to say

x_lookup = rstInpt!NP3

I tried using the variable name a few different ways with no results.
Not found in this collection.

Hope I explained this correctly ?

Thanks

Skip Hooper

[This message has been edited by skiphooper (edited 02-02-2001).]
 
Try something like
Public Function rstInpt(fldName as string)as Variant

your code here to get data etc.

rstInpt = whatEverData
End Function

your call to the function would be
x = rstInpt
 
Keith,
Thanks for the reply.
The real problem, ( I guess I really didn't
explain well enough is )
The arguments passed to the function are

1 - the table to search

2 thru 6 - are fields values to compare to.
These 6 fields are all option, by placing a
value for one of these I know the field name
already. These field names are in most
any table the user might ask for.

7 - another field name to compare (

8 - the value to search for

9 - compare type ( ex "<=" , "=", "<>" )

10 - The field name to return

How do I returm the value for # 10
when all I have is a variable with the
field name in it . ( I have no Idea what
field name the user will ask for until the
variables are read. )


Thanks
Skip

[This message has been edited by skiphooper (edited 02-03-2001).]

[This message has been edited by skiphooper (edited 02-03-2001).]
 
try this x_lookup = rstInpt.Fields(fldName)

in thisfldName is the tenth argument being passed to your function. I believe you said that that argument was the name of the field whoose value you want to return

ntp
 
Hi ntp,
Thanks a lot.
Your reply was exactly what I needed.

Thanks Again

Skip
 

Users who are viewing this thread

Back
Top Bottom