hello
I think I'm missing something really obvious.
As shown below, I generate the NAMES of 48 queries that I am about to create and save in a loop. This works fine.
In the For-Next loop, I generate the SQL code for each QueryDef, but I'm having trouble with the NAMEs of the QueryDefs.
For example, when n = 48, I want ...
strQryOutput = "q91c__D2E2_...etc...", NOT strQryOutput = strSQL_n48
Is there an easy fix?
Thanks in advance
I think I'm missing something really obvious.
As shown below, I generate the NAMES of 48 queries that I am about to create and save in a loop. This works fine.
In the For-Next loop, I generate the SQL code for each QueryDef, but I'm having trouble with the NAMEs of the QueryDefs.
For example, when n = 48, I want ...
strQryOutput = "q91c__D2E2_...etc...", NOT strQryOutput = strSQL_n48
Code:
... CODE HERE...
strSQL_n01 = "q91a__A1B1_" & rl_AB & "_tt_DE_" & rl_DE & "___and___D1E1_" & rl_DE & "_tt_AB_" & rl_AB
strSQL_n02 = "q91a__A1B1_" & rl_AB & "_tt_DE_" & rl_DE & "___and___D1E2_" & rl_DE & "_tt_AB_" & rl_AB
... etc ...
strSQL_n48 = "q91c__D2E2_" & rl_DE & "_tt_GH_" & rl_GH & "___and___G2H2_" & rl_GH & "_tt_DE_" & rl_DE
For n = 1 To 48
.... CODE HERE to build strSQL...
[b] [COLOR=#CC0000]strQryOutput[/color] = "strSQL_n" & Right(CStr(0) & CStr(n), 2) <------ INCORRECT[b][/b][/b]
Set db = CurrentDb
'create saved qry
[b] Set MyQueryDef = db.CreateQueryDef([COLOR=#CC0000]strQryOutput[/color], strSQL)[/b]
Set MyQueryDef = Nothing
db.Close: Set db = Nothing
Next n
Is there an easy fix?
Thanks in advance