About Miguel Zapico Expertise I can answer question about how to use scripts to consolidate data, connect different systems and automate tasks. I have no experience on using VBScript on web programming.
Experience I have been using VBScript and Windows Scripting Host as my swiss tool for the last 6 years.
Organizations New York PC users group (NYPC)
Independant Computer Consultants Association (ICCA)
Education/Credentials Microsoft MCSE in Windows NT
Expert: Miguel Zapico Date: 6/16/2006 Subject: DATA GRID
Question Hi,
I was wondering if someone could help me. I am developing a form in vb 6.0
which has a MS Access db running behind it. On the from, I have a
data grid which retrieves the information of customers (name, payment …..)
From that db and outputs it to the screen.
My problem is that I need to create a button on which I click
And should give me the sum of payments (on a label) of all customers and another
button for the sum of payments for each customer (on a label). I am sure that I have to use SQL but how to do it please.
By the way I did the DB Access connection not in code , I did it manually in the properties of the adodc.
Thank you very much.
Answer I don't have vb installed, so I'll try to answer the best I can. This is a code that queries a database in vbscript, it may give you some ideas.
Sub AskData()
Dim strSQL
set miRec = CreateObject("ADODB.Recordset")
strSQL = "SELECT SUM(Payments) FROM Customers"
With miRec
.ActiveConnection = gconIT
.Open strSQL
WScript.Echo .Fields(0).Value
End With
miRec.Close
End Sub
The idea is, create a connection object (that is the gconIT, you may need to know how your connection is called), create a ADODB.Recordset, that will use that connection, and with the method Open of the recordset you can craft a SQL expression.
If you have doubts about the SQL expression, do it in Access with the wizard, and then see the code on the SQL view.
In order to put on a label, change the Wscript.Echo order to the appropiate label changing code.