I need to concatenate fields in a table using DAO. My problem is that there can be up to 40 fields to be joined and the code is getting rather lengthy. I don't know how many fields there are for each record until the field is tested for a null value. The only approach that I can think of is pretty ugly. Assume F1 to F40 are the fields of the recordset, and stTemp is the variable used to collect the string.
If not IsNull(!F1) then stTemp = StTemp & !F1 else exit
If not IsNull(!F2) then stTemp = stTemp & !F2 else exit
You get the idea. Should be a more elegant way than this crude, brute force method.
A for-next loop won't work because the field names can't be constructed from a variable. For-each doesn't work on recordsets. Do-While is attractive, but I can't figure any way of using a variable to represent the field names.
Any ideas?
AvGuy
If not IsNull(!F1) then stTemp = StTemp & !F1 else exit
If not IsNull(!F2) then stTemp = stTemp & !F2 else exit
You get the idea. Should be a more elegant way than this crude, brute force method.
A for-next loop won't work because the field names can't be constructed from a variable. For-each doesn't work on recordsets. Do-While is attractive, but I can't figure any way of using a variable to represent the field names.
Any ideas?
AvGuy