if you are storing all of your variables in tables you don't need to populate a form at all but if you want to continue populating data in your form you can do this:
Let's say you have a table called 'tblStoredVariables
on that table your data looks like:
Code:
ID Report_Brand Store_No Var1 Var2 Var3 ----> remainder of your variables
Further let's say you have a form called frmSetup with a combo box for both your REPORT_BRAND (cboReportBrand) and STORE_NO (cboStoreNo)
Now on your form you have fields called Variable1, Variable2, Variable3
after you've selected the store no you can do this:
Code:
dim db as database
dim rst as recordset
dim sSQL as string
dim iID as long
iID = dlookup("[ID]", "tblStoredVariables", "[Report_Brand] = " & forms!frmSetup!cboReportBrand & " AND [Store_No] = " & cbostoreno )
'(NOTE: This assumes your report brand and storeno identifiers are NUMBER VALUES, the dlookup changes a bit if they are text values)
set db = currentdb
ssql = "SELECT * FROM tblStoredVariables WHERE (ID] = " & iid & ")"
set rst = db.openrecordset(ssql)
'THERE SHOULD BE ONLY 1 RECORD FOR EACH REPORT_BRAND AND STORE_NO PAIR
if rst.recordcount <> 0 then
rst.movefirst
Variable1 = rst.fields("var1")
Variable2 = rst.fields("var2")
Variable3 = rst.fields("var3")
endif
rst.close
set db = nothing
if the form is correctly populating with your values you can then attach all your queries you want to run to the end of the code
you can of course cycle through ALL your stored variables the same way so that you could, theoretically, choose the report combinations you wanted to run from, say, a multi select list box and click one button and have it cycle through everything you want to run with a single click.