AccessTr.neT
Sorgu Sonucunu Toplama - 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ığı: Sorgu Sonucunu Toplama (/konu-sorgu-sonucunu-toplama.html)

Sayfalar: 1 2


Sorgu Sonucunu Toplama - husem - 14/11/2021

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][Resim: do.php?img=11395][/img]

sorgu sonucu:
[img][Resim: do.php?img=11396][/img]

yapmaya çalıştığım (takıldığım nokta), sorgu sonucunu nasıl toplayabilirim?


RE: Sorgu Sonucunu Toplama - husem - 14/11/2021

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


RE: Sorgu Sonucunu Toplama - lemoncher2 - 14/11/2021

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


RE: Sorgu Sonucunu Toplama - husem - 14/11/2021

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,


RE: Sorgu Sonucunu Toplama - lemoncher2 - 14/11/2021

Bir örnek eklermisin inceleyelim daha kolay yardımcı olmuş oluruz.


Re: Sorgu Sonucunu Toplama - husem - 14/11/2021

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