Parameterized Query?

N

Noor

Hi

Can we assign parameterized queries to recordsource property of forms??
if yes, then how can we provide parameter to that query?


thanks
Noor
 
E

Emilia Maxim

Noor said:
Can we assign parameterized queries to recordsource property of forms??
if yes, then how can we provide parameter to that query?

Noor,

the question is, what would you want to achieve? Would you want to
open the form with one or more selected records?

Best regards
Emilia

Emilia Maxim
PC-SoftwareService, Stuttgart
http://www.maxim-software-service.de
 
J

John Vinson

Hi

Can we assign parameterized queries to recordsource property of forms??

Certainly. Very routinely done in fact.
if yes, then how can we provide parameter to that query?

Probably the most convenient way is to use a separate unbound Form to
provide the parameter. If you have a form, frmCrit, with a textbox (or
combo box or other control) txtCrit, you can use a criterion

=[Forms]![frmCrt]![txtCrit]

on your Query, and put a button on frmCrit to open your data display
form.
 
N

Noor

Actually i have a very long and complex query that takes a criteria to
accomplish.
In the current scenario, i have to write the whole query as sql statement in
my form module, with parameter, and then assinging it to the form
recordsource.

It's going well, but i just want to ask you people if there's way to make
this query a parameter query and then assign it to the form recordsource at
design time and provide a just provide the parameter at runtime.. so query
can execute.
 
E

Emilia Maxim

Noor said:
Actually i have a very long and complex query that takes a criteria to
accomplish.
In the current scenario, i have to write the whole query as sql statement in
my form module, with parameter, and then assinging it to the form
recordsource.

It's going well, but i just want to ask you people if there's way to make
this query a parameter query and then assign it to the form recordsource at
design time and provide a just provide the parameter at runtime.. so query
can execute.

Noor,

it seems, you want to change the form data at runtime, i.e. the form
should display different recordsets depending on some criteria without
closing it. Would then setting the form filter instead of using a
parameter query be a solution?

If you need just to open the form based on some criteria, then you can
use the solution described by John. Other solutions would be:
- write a public function and use it as a parameter
- use a query without parameter and set the WhereCondition of the
OpenForm statement as needed.

If all this does not fit, maybe you can give some more details.

Best regards
Emilia

Emilia Maxim
PC-SoftwareService, Stuttgart
http://www.maxim-software-service.de
 

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