I was having some issues with retrieving the SUM from a column in my access database and displaying the value in a html textbox.--This i was able to fix with the function below.
Issue: I've found that the below function works fine to retrieve the sum. But for some reason, if a value changes in my database, the SUM does not get updated when the function is called again.
Here is how i found it has something to do with the memory not getting refreshed/cleared in Access
I made a "copy" of my access DB, renamed it to something different, changed the values in the column im summing, and updated the code with the new DB path. once i did this, my textbox populated the correct sum. Again, if i changed values in this DB copy, the new sum would not refresh..
It appears that access is unable to clear the last query run and must be done before i run my SUM function. And this is something i'm clueless about writing in JS. hoping someone has encountered this before.
Here is the working function that retrieves the SUM from a column in my DB:
Thank you for reading this far. Desperately looking for some help :confused:
var adoconn = new ActiveXobject("ADODB.Connection");
var cmd = new ActiveXObject("ADODB.Command");
cmd.ActiveConnection = adoconn;
var adoRS = new ActiveXobject("ADODB.Recordset");
var strSQL = "Select SUM(database_column_name) As Total FROM tablename";
cmd.CommandText = strSQL;
adoRS = cmd.Execute();
textbox1.value = adoRS.Fields(0);