Parameter Query to Function

G

Guest

This is probably very simple, but any help would be appreciated. I have a
parameter query that prompts user to input Destination. Instead of putting
the prompts in the criteria field I would like to build a module/function
that does this and then call this from the query.

I have the module/function built, but I tried calling it by destInput() in
the criteria field and I get an error. Any ideas? The name if the module is
DestinationInput the name of the function is desInput(). The only thing the
function does is ask user for Destination and set that value to strInput
 
T

Tim Ferguson

I have the module/function built, but I tried calling it by
destInput() in the criteria field and I get an error.

It shoud work if you mean something along the lines of

PARAMETERS DestInput TEXT
SELECT Something FROM Somewhere
WHERE Destination = DestInput;
the name of the function is desInput(). The only thing the
function does is ask user for Destination and set that value to
strInput

There may be a problem with the function return: you need to assign the
value back to the (pretend) variable with the function name:

public function DestInput() As string
Dim strInput as String ' temp variable
' get the value
strInput = InputBox("Hello", "")

' return the value by using the DestInput
' pseudovariable
DestInput = strInput

End Function


Then you can do something like this in the immediate window:

? DestInput
Holland

and you know it's working.


Hope that helps


Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top