I am trying to get a percentage of how many products have been counted by using SQL statements. I have one that returns how many have been counted (checked) and another for how many have not been counted (needToCheck). I get a datatypoe mismatch when I try to equate the long variables to the connection execution. I was wondering if any knew how I could get the numbers I want easily rather than looping through the table twice. I would like to just be able to divide checked by needToCheck and multiply by 100 and output it to a label to let people know how far along they have come. Any suggestions? Thank you.
VB Code:
Private Sub completed() Dim checked As Long Dim needToCheck As Long Dim sql As String Set connection = New ADODB.connection connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source= G:\Finance\Inventory Control\CycleCount\DB\cycleCount.mdb" connection.Open sql = "SELECT Count(PROD) AS Expr1 " & _ "From TOGO " & _ "WHERE (((TOGO.CHECKED)=TRUE));" checked = connection.Execute(sql) sql = "SELECT Count(PROD) AS Expr1 " & _ "From TOGO " & _ "WHERE (((TOGO.CHECKED)=FALSE));" needstoCheck = connection.Execute(sql) End Sub




Reply With Quote