AccessTr.neT
Access Countıf Fonksiyonu - Baskı Önizleme

+- AccessTr.neT (https://accesstr.net)
+-- Forum: Microsoft Access (https://accesstr.net/forum-microsoft-access.html)
+--- Forum: Access Cevaplanmış Soruları (https://accesstr.net/forum-access-cevaplanmis-sorulari.html)
+--- Konu Başlığı: Access Countıf Fonksiyonu (/konu-access-countif-fonksiyonu.html)



Access Countıf Fonksiyonu - truhi - 08/04/2024

Merhaba,
Bir Numara' nın daha önce kayıt edilip edilmediğini öğrenmek için aşağıdaki gibi bir fonksiyon oluşturdum ama;
Set RS = db.OpenRecordset(SQL) satırında ekli görseldeki hata mesajını vermekte,

Sebebi neden kaynaklanabilir,
alternatif olarak Acceste Excel benzeri bir CountIF fonksiyonu var mıdır?
web' de =Count(IIf([Service]="Housing",1)) bu şekilde bir çözüm gördüm ama; bende IFF fonksiyonu nu tanımadı.

teşekkürler,
iyi Çalışmalar.


Kod:
Private Sub Metin130_AfterUpdate()
Dim c As Byte
Dim deg As Long

''On Error Resume Next

deg = CLng(Me.Metin130.Value)
    c = GetCount(deg)

    If c > 0 Then
        MsgBox "Bu 'CSO Number' önce kaydedilmiş..", vbExclamation, "Uyarı"
        Metin130.SetFocus
    End If
  

End Sub


Kod:
Private Function GetCount(deg As Long) As Byte
Dim db As DAO.Database
Dim RS As DAO.Recordset
Dim SQL As String

Set db = CurrentDb()

SQL = "SELECT count([Number]) FROM Data" & _
       " WHERE [Number]=" & deg

Set RS = db.OpenRecordset(SQL)

    GetCount = RS(0)

RS.Close

Set RS = Nothing
Set db = Nothing
    
End Function




RE: Access Countıf Fonksiyonu - atoykan - 08/04/2024

DSum, Dmax, Dmin, Dlookup gibi yerleşik bir işlevler varken bu tip fonksiyonlara neden ihtiyaç olsun?


RE: Access Countıf Fonksiyonu - truhi - 08/04/2024

(08/04/2024, 20:34)atoykan yazdı: DSum, Dmax, Dmin, Dlookup gibi yerleşik bir işlevler varken bu tip fonksiyonlara neden ihtiyaç olsun?

Teşekkürler Hocam
DCount ile çözdüm