Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2011
    Posts
    9

    Red face Unanswered: Counting Assests

    i want to design a module to count each assets on a table so i can generate an aggregated data report of for each item. this is where i got stuck:Help!
    Code:
    Private Sub countAssets()
     Dim mydb As Database, MysetAssets As Recordset, MysetSoftware As Recordset
        Set mydb = DBEngine.Workspaces(0).Databases(0)
    '............................................................................
        
        Set MysetAssets = mydb.OpenRecordset("qryAssetDetails", DB_OPEN_DYNASET)
        Set MysetSoftware = mydb.OpenRecordset("qrySoftwareDetails", DB_OPEN_DYNASET)
        
        Dim assName As Field, assStatus As Field, assCondition As Field
        Dim countName As Integer, countStatus As Integer, countCondition As Integer, Found As Boolean
        Dim foundName As String, foundStatus As String, foundCondition As String
        
        Set assName = MysetAssets![equipCatName]
        Set assStatus = MysetAssets![equipStatus]
        Set assCondition = MysetAssets![assCondition]
        countName = 0
        countStatus = 0
        countCondition = 0
        Found = False
        
        MysetAssets.MoveFirst
        Do Until MysetAssets.EOF
            Case assName <> ""
            Found = True
            Dim strWhere As String
     
        strWhere = "(foundname=#" & assName & "#) AND " & _
                   "(foundstatus='" & assStatus & "')"
                   
        
            
            Case Else
            
            End Select
        Myset.MoveNext
        Loop
    End Sub

  2. #2
    Join Date
    Jun 2011
    Location
    Inside your mind
    Posts
    297
    Not enough info to help...

    But for a start, in SQL #someValue# indicates a date, not a name.

    What are these 'assests'? Are they just data in a particular column of a table? If so, look up the 'COUNT()' SQL function.
    Last edited by kez1304; 08-16-11 at 08:33.
    Looking for the perfect beer...

  3. #3
    Join Date
    Aug 2011
    Posts
    9

    Angry counting assets..

    i just have a table to store different assets in a field called assName eg; CPU, Monitor, UPS, Table...etc. so what i want to do is to design a module that can counts each item separately. for example i used to use a module below to do this.
    Code:
    Do Until Myset.EOF
            Select Case AssetName
                Case Is = "CPU"
                    countCPU = countCPU + 1
                Case Is = "Monitor"
                    countMonitor = countMonitor + 1
                Case "UPS"
                    countUPS = countUPS + 1
                Case Is = "Kettle"
                countKettle = countKettle + 1
                Case Is = "Book"
                countBook = countBook + 1
                Case Is = "TV"
                countTV = countTV + 1
                Case Else
                    countothers = countothers + 1
        End Select
        Myset.MoveNext
        Loop
    this module worked just fine the problem is, i need to amend it if a new item is introduced so i need to design a module which will just move to the first record in a table and finds items and start counting without being amended.

    hope this will give you enough information. my regards

  4. #4
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,418
    Provided Answers: 7
    Why don't you just write a query group by assist and count the number of I'd done
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •