Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 3rd, 2012, 01:24 PM
Registered User
 
Join Date: Oct 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default VB to calculate count of distinct values

hi i currently have a student_Details ms access table with the fields - "ID" and "Skills".and another table called Category with field "category" which stores the distinct skills of the students
I have used the following VB code to calculate the distinct skills from the Student_details table
Code:
Option Compare Database

Private Sub Command0_Click()
strSQL = "select distinct(Skills) from Student_Details"
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL)
Do While Not rs.EOF
        If rs(0) <> Null Then  'The real loop exit condition.
            Exit Do
        End If
        Debug.Print (rs(0));
        DoCmd.SetWarnings (False)
        a = "insert into Category values ('" & rs(0) & "');"
        DoCmd.RunSQL a
         DoCmd.SetWarnings (True)
        rs.MoveNext
    Loop

End Sub
Now i need to calculate the count of the distinct skills from the Student_details table and store it in the Category table as a column corresponding to each distinct skill





Similar Threads
Thread Thread Starter Forum Replies Last Post
Count Distinct Jonas Access 2 August 14th, 2006 01:03 PM
count distinct values Chris Cash XSLT 3 June 8th, 2006 04:55 PM
count distinct nodes alexshiell XSLT 2 January 27th, 2005 11:19 AM
sql to return distinct count pbgurl Access VBA 2 October 29th, 2004 06:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.