Dim SQL1 As SQL
Dim MyQuery As String
Dim db_cursor As Cursor
Dim somma As Double
MyQuery = "SELECT SUM(CAMPONUMERICO) AS SOMMACAMPONUMERICO FROM NOMETABELLA"
db_cursor = SQL1.ExecQuery(MyQuery)
somma = db_cursor.GetDouble("SOMMACAMPONUMERICO")
db_cursor.Close
This will for sure not work: total = "SELECT SUM(Importo) FROM " & Main.SelectedTable
This works: total = SQL1.ExecQuerySingleResult("SELECT sum(Importo) FROM " & Main.SelectedTable)