I can't say that sql will be much faster.
In fact, that dsum is converted to sql anyway.
The advantage of using a expression as you have now is that ms-access can
then figure out "when" to display it.
You could convert the whole thing to code and some sql, but I then you need
to "fire" the code, and that can be a pain in the neck.
You could use the forms on-current, but often during form loading, or
navigating, or entering a new record, you don't yet have the data.
Before you convert, I would MAKE SURE that you got a index on the SalesID
field.
However, for the sake of learning, here is what the code could look like:
dim rstResults as dao.ReocrdSet
dim strSql as string
if nz(me!SalesID,0) <> 0 then
strSql = "select sum("Expr4") from DollDetaisQ where Taxed = True" & _
" and SalesID = " & me!SalesID
set rstResults = currentdb.OpenReocrdSet(strSql)
if rstResults.RecordCount > 0 then
me.Text40 = rstResults(0)
end if
rstResults.Close
set rstResults = nothing
end if