Sorgu Sonucunu Toplama

1 2
14/11/2021, 11:22

husem

merhaba arkadaşlar,
aşağıdaki sorgu ile tarih aralığına ait kumaş dokuma birimine ait doluluk oranı hesaplıyorum,
tarih aralığına ait tüm verileri listeliyorum,
kod:
Kod:
Private Sub DOKUMA_DOLULUK()

ARAILK = ">=#" & Month(Me.ARAILKTARIH) & " / " & Day(Me.ARAILKTARIH) & " / " & Year(Me.ARAILKTARIH) & "#"
ARASON = "<=#" & Month(Me.ARASONTARIH) & " / " & Day(Me.ARASONTARIH) & " / " & Year(Me.ARASONTARIH) & "#"

Dim rs As New ADODB.Recordset
rs.Open "SELECT Sum([en]*[boy]*[gramaj]*1.05*1.08*[adet]/10000000) AS DOLULUK From SIPARIS_KAYIT GROUP BY SIPARIS_KAYIT.YUKLEME_TARIHI HAVING (SIPARIS_KAYIT.YUKLEME_TARIHI" & ARAILK & ") AND (SIPARIS_KAYIT.YUKLEME_TARIHI" & ARASON & ")", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If Not rs.EOF Then
'
MsgBox RoundA(rs("DOLULUK"))

Else
End If
rs.Close
End Sub

tarih aralığına ait tüm verileri listeliyorum,
sorgu :
[img]

sorgu sonucu:
[img]

yapmaya çalıştığım (takıldığım nokta), sorgu sonucunu nasıl toplayabilirim?
14/11/2021, 11:50

husem

aşağıdaki gibi yapmaya çalıştım ama olmadı.
Private Sub DOKUMA_DOLULUK()

ARAILK = ">=#" & Month(Me.ARAILKTARIH) & " / " & Day(Me.ARAILKTARIH) & " / " & Year(Me.ARAILKTARIH) & "#"
ARASON = "<=#" & Month(Me.ARASONTARIH) & " / " & Day(Me.ARASONTARIH) & " / " & Year(Me.ARASONTARIH) & "#"

Dim rs As New ADODB.Recordset
rs.Open "SELECT Sum([en]*[boy]*[gramaj]*1.05*1.08*[adet]/10000000) AS DOLULUK From SIPARIS_KAYIT GROUP BY SIPARIS_KAYIT.YUKLEME_TARIHI HAVING (SIPARIS_KAYIT.YUKLEME_TARIHI" & ARAILK & ") AND (SIPARIS_KAYIT.YUKLEME_TARIHI" & ARASON & ")", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If Not rs.EOF Then
'
MsgBox RoundA(rs("DOLULUK"))
Dim i As Long, Sonuc1 As Double
For i = 1 To rs.Fields.Count - 1
Sonuc1 = Sonuc1 + rs.Fields(i).Value
Next i

MsgBox Sonuc1

Else
End If
rs.Close
End Sub
14/11/2021, 12:08

lemoncher2

Merhaba 2 yöntem aklıma geldi.

1) YUKLEME_TARIHI sütununu sorgudan kaldırdığınızda
2) bu oluşturmuş olduğunuz sorgunuzu başka bir sorguda FORM olarak ekleyip DOLULUK alanını toplamasını isteyerek

Hepsinin toplamını alabilirsiniz
14/11/2021, 12:11

husem

merhaba,
1.yöntem dediğiniz olumsuz, çünkü tarih aralığına göre veri alamam o zaman
2.yönetim: kod ile işlemi bitirmek istiyorum gibi ;)
önerin için teşekkür ederim,
14/11/2021, 12:12

lemoncher2

Bir örnek eklermisin inceleyelim daha kolay yardımcı olmuş oluruz.
14/11/2021, 12:58

husem

(14/11/2021, 12:12)lemoncher2 yazdı: Bir örnek eklermisin inceleyelim daha kolay yardımcı olmuş oluruz.
1 2