How to create a "dynamic" sql code

A

andre_29

Dear all,

I am trying to bring some data from ms access to ms excel and I need
to create a "dynamic" sql code .

I have a form in excel with 4 checkbox: so se user can select: entity,
division, scenario, period.

After this excel will create a query in ms access to bring the data.

The user can select: entity/division/scenario/period or entity/period
or entity or division etc etc etc (a lot of combinations....)

I did this sql code, but I don't know how do it following the user
selection (this code is only if user select entity/division/scenario/
period at the same time):

strSQL = "SELECT entity, division, scenarioperiod, Sum(tbl_sales.qty)
AS qty2, FROM tbl_sales
strSQL = strSQL & "GROUP BY entity, division, scenario, period "
strSQL = strSQL & "HAVING (((tbl_sales.entity) Like '*') AND
((tbl_sales.division) Like '*') AND ((tbl_sales.scenario) Like '*')
AND ((tbl_sales.period) Like '*')) ;"

Thank in advance!!!!!!

André.
 
A

AdamV

Sounds like you need parameters - the MS Query editor might be able to
help you build those, so you can link part of your query to a cell (and
in that cell you may need a formula to parse together some things from
your other options, by the sound of it)
 

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