Arthur Fuller
fuller.artful at gmail.com
Mon Nov 12 17:50:37 CST 2007
Can one pass a recordset as a parameter to a function. I guess I could write a quick tester to determine this, but I'm in the middle of something else. If I could do this, I could seriously simplify some hairy code that I inherited. Just as an aside and casual invitation to start another lengthy debate, all this inherited code is based on dynamically building SQL statements using the values contained in a recordset. A typical example would be: sDocMemo = sDocMemo _ & " is too close to the pinch point. It is " & Nz(rsLCData!DisToPinchPoint1, 0) _ & " millimetres away and should be at least " _ & Nz(rsLCData!DsPP1_ShouldBe, 0) & " millimetres away from the Pinch Point." _ & " " & sBlankedBeamsText Oh God, I hate this style of coding. It makes me crazy. It may work but even with the logical line breaks it's hard as hell to read (or maybe I'm just getting too old for this business. There are a bunch of text-assembly blocks like this all stuck into one huge (1000+ lines) procedure. My plan is to break each text-assembly chunk out into a function that accepts a recordset as a parameter and builds the string and returns it. If I can't pass the recordset, then I'll grab its values and pass those instead, and break this 1000-liner into about 20 5-liners (or less lines per function), which fetch the text from a table and then whose content uses a syntax like this: The ///LCPosition1/// light curtain is too close to the pinch point. It is ///DisToPinchPoint1/// millimetres away and should be at least ///DsPP1_ShouldBe/// millimetres away from the Pinch Point. The given function will use Replace() to find the triple-shlash-delimited insertion-points and replace them with the passed parameters, then return the string. Anyone see any problems with this approach? TIA, Arthur