Uncle Gizmo
05-05-2006, 05:28 AM
I find myself using both DAO code and ADO code in the same functions. I am gradually learning how to change the old DAO into ADO. I have just succeeded with a routine for extracting the field names from a table, query. See attached for more information.
Any improvement, comments you can make welcome.
Uncle Gizmo
12-18-2006, 09:21 AM
Found it!
It has taken me hours and hours to find this piece of code!
Sub get_SQL_Sum()
'http://www.oreilly.com/pub/h/3323
Dim conn As ADODB.Connection
Set conn = CurrentProject.Connection
Dim rs As New ADODB.Recordset
rs.Open "Select Sum(Amount) As SumOfAmount From Invoices" & _
" Where InvoiceDate=#12/10/04#", _
conn, adOpenKeyset, adLockOptimistic
MsgBox rs.Fields("SumOfAmount")
rs.Close
Set rs = Nothing
Set conn = Nothing
End Sub