insert string into middle of string

G

Guest

I'm trying to build a FROM clause from code, depending on the choices taken
in a form with multiple controls. Basically, it goes like this (hypothetical
names):

if ctl1.value = true then
fromsql = "FROM TABLE1 INNER JOIN ON TABLE1.FIELD1 = ROOT.FIELD1"
end if

if ctl2.value = true then
fromsql = fromsql & "TABLE 2 INNER JOIN ON TABLE2.FIELD2 = ROOT.FIELD2"

This is where my problem begins, since a proper FROM statement has to have
other innerjoin statments placed in the first (eg. from TABLE1 inner join
(TABLE2 inner join (TABLE3 inner join on TABLE3.FIELD3 = ROOT.FIELD3) on
TABLE2.FIELD2 = ROOT.FIELD2) on TABLE1.FIELD1 = ROOT.FIELD1.

Therefore, in order for me to do this, i think i need to insert the second
statement into the middle of the first, but I dont know how...

Please advise,
Thanks,
 
G

Guest

The Replace function can be useful for this or you can construct the SQL
string in pieces based on the control values.
 

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