Results 1 to 5 of 5
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    count rkds based var (2000)

    With this piece of code how to count numer of records(and store in var Conta_Record1) distinct records based value in var = COD_AREA in field REGIONE in table SPORTELLI:

    Sub FILL_COMBO1(COD_AREA)

    Set CN = New ADODB.Connection
    Set RS = New ADODB.Recordset

    'UFFICIO
    CN.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=GCD01F4500DATIPUBBLICAAPPLICAZIONIAREA.MDB; "
    'UFFICIO

    'CASA
    'CN.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:MAPPAAREA.MDB;"
    'CASA

    sSQL = "select REGIONI from REGIONI where CODICE = '" & COD_AREA & "' ORDER BY REGIONI ASC"
    RS.Open sSQL, CN, adOpenKeyset, adLockOptimistic

    'Conta_Record1 = DCount("*", "SPORTELLI", "REGIONE Like 'COD_AREA'")


    BNP_BNL.Combo1.Clear

    Do While Not RS.EOF
    BNP_BNL.Combo1.AddItem (RS.Fields(0))
    RS.MoveNext
    Loop

    RS.Close
    CN.Close
    Set RS = Nothing
    Set CN = Nothing

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: count rkds based var (2000)

    Since you're looping through the records anyway, you could use

    Do While Not RS.EOF
    BNP_BNL.Combo1.AddItem (RS.Fields(0))
    Conta_Record1 = Conta_Record1 + 1
    RS.MoveNext
    Loop

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: count rkds based var (2000)

    tKS...
    But my question really is:
    How to count in field REGIONE all records=COD_AREA...
    For example: count all record in filed REGIONE=8505 in this case are 138
    note: use table SPORTELLI

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: count rkds based var (2000)

    Sorry, I didn't read your original question carefully. Try this:

    sSQL = "SELECT COUNT(*) AS Cnt FROM SPORTELLI WHERE REGIONE = '" & COD_AREA & "'"
    RS.Open sSQL, CN, adOpenKeyset, adLockOptimistic
    Conta_Record1 = RS!Cnt
    RS.Close

    sSQL = "select REGIONI from REGIONI where CODICE = '" & COD_AREA & "' ORDER BY REGIONI ASC"
    RS.Open ...

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: count rkds based var (2000)

    no worry...
    Sorry me instead for delay, but the Boss call me for breafing.
    Naturally all work fine, now.
    Tks.

Posting Permissions

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