Can you silently pass a parameter without VBA?

scottydel

Registered User.
Local time
Today, 16:41
Joined
Apr 18, 2007
Messages
35
Hello,

Can Access handle paramater-passing without getting into the object model and adding a "Parameter" datatype to a query and calling DoCmd.RunSQL etc, and also without prompting the user?

Is something like this possible (as it is in SQL Server I believe):

SELECT * FROM some_query_that requires_a_parameter(param_value='china')

I am trying to avoid the annoying bit where Access Prompts you for a parameter with the little popup, and I'm also trying to avoid the little bit called "programming it with VBA".

I'd like to see if this can be done with only a SQL query in Access.

Any thoughts are appreciated!

Thanks,

Scott
 
Assume query named MyQuery with the following SQL:
Code:
SELECT * FROM MyTable
WHERE MyTable.Country=[ParamCountry];

...and you want to call this query from an SQL statement, passing "China" to the parameter ParamCountry.

You would use:
Code:
PARAMETERS [ParamCountry] Text = 'China';
SELECT * FROM MyQuery;
 
Thank you bytemyzer that's exactly what i was looking for.
 
I've used the code below and I'm getting an error pop-up:

Wrong data type for parameter 'ParamCountry'.

MyTable.Country is of type Text.

Any ideas?
 
Was missing a set of [] in the original query, nevermind.
 

Users who are viewing this thread

Back
Top Bottom