In VBA, there are times when you might want to pass an indeterminant number of arguments onto a function. In the VB world, paramarray handles such. But what if one needs, in turn to pass such onto a sub-function?
In the challenge here, I have a couple of different places that format a string, inserting subsequent values, for example:
tx = SetSQL("UPDATE tabA SET cd={1} WHERE id={2}", "'123'", 89)
Depending upon the situation, there might be 1 or n parameters.
This worked well when I handled all the SQL directly. For example:
set rsNEW = currentdb.execute (SetSQL("UPDATE tabA SET cd={1} WHERE id={2}", "'123'", 89))
But, I then found that I had several situations where the same processing was repeated and I wanted to refactor some of that into a more all encompassing call some of the time. I wanted to wrap the SetSQL
inside of another routine. For example:
public sub DoMyDBThing("UPDATE tabA SET cd={1} WHERE id={2}", "'123'", 89)
And this put me in a situation where I needed to transfer a paramarray
to a paramarray
.