I have a query that just reads one table and appends to an output
table, one-for-one. No criteria. It's not a Total query (i.e. no
group by). It normally run run in minutes, but gets horribly slowed
down because five of my output fields are text fields and the
expression that gets appended is a user-defined function I wrote which
is very simple (just a few lines long). Here's the code of my
function:
Public Function tformat(num As Double, xdec As Byte) As String
If xdec = 0 Then
tformat = Right(Space(12) + Format(num), 12)
Else
tformat = Right(Space(12) + Format(num, "0." + String(xdec,
"0")), 12)
End If
End Function
In each of the 5 expressions in my query grid, the parameters I pass
are:
num: a numeric field from the query's input table
xdec: a numeric literal constant.
The above function looks fairly simple, but it causes my query which
otherwise would run in a few minutes to take many times that long to
finish (maybe an hour). Do any of you understand why, or maybe have a
helpful suggestion about a trick I could use to speed up my query?