JohnW Posted April 2, 2009 Share Posted April 2, 2009 I am trying to find a could way to tally up some field counts by a model number. What I have is a database that has a model # and then a bunch of different fields that have different reasons for reject codes. I need to tally up by model # and field the number of times it was rejected for a reason which is the value in that field. I can do like below but I would like a way that it would automatically go through and collect model #'s field names and reject codes under those field names. $sqlCon = ObjCreate("ADODB.Connection") $sqlCon.Open("DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\PDI Cheklist Database.mdb",3,3)</P> <P> $fieldQueryName = "G1 Load Arm Support Device" $fieldQueryValue = "31 Won''t Function" $fieldQueryName2 = "Model #" $fieldQueryValue2 = "3640" $adoRs = $sqlCon.Execute("Select Table1.[Model #],Count(*) AS G1Count From Table1 Where Table1.[" & $fieldQueryName & "]='" & $fieldQueryValue & "' and Table1.[" & $fieldQueryName2 & "]='" & $fieldQueryValue2 & "' GROUP By Table1.[Model #]") $J = $adoRs.Fields.Count -1 For $I = 0 to $J $TXT = $adoRs.Fields($I).Name $TXT = $TXT & " " & $adoRs.Fields($I).Value MsgBox(4096,"",$TXT) Next $sqlCon.close Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now