G
George Papadopoulos
I have written the code below
Private Sub Anazhthsh_Click()
Dim strSelect As String
Dim intLoop As Integer
Dim intKwdikos_Episkeyhs As Integer, sum1 As Integer, Totalsum As Integer
Dim dbEPEMBATHS As Database
' Make a connection to the database
Set dbEPEMBATHS = CurrentDb
strSelect = "Select Kwdikos_episkeyhs, Kwdikos_klinikhs,
Kwdikos_mhxanhmatos FROM EPISKEYH WHERE" _
& " (Hmeromhnia >= #" & Me.From_Date & "#)" _
& " and (Hmeromhnia <= #" & Me.To_Date & "#)" _
& " and (Aitia_blabhs =" & Me.btnKakh_xrhsh & ")"
'Fill in the list box
[list_Episkeyes].RowSource = strSelect
' Loop through table aggregating each sum
For intLoop = 1 To Me!list_Episkeyes.ListCount - 1
intKwdikos_Episkeyhs = Me!list_Episkeyes.Column(0, intLoop)
strSelect = "Select Sum(Kostos) FROM ANTALLAKTIKA WHERE
Kwdikos_episkeyhs =" & intKwdikos_Episkeyhs
sum1 = dbEPEMBATHS.OpenRecordset(strSelect).Fields(0).Value
Totalsum = Totalsum + sum1
Next intLoop
Me.Oliko_kostos.Value = Totalsum
End Sub
I`m experiencing this problem with the strSelect in the For loop. When the
criterion for the Select statement is not satisfied the OpenRecordset
statement fails with an 'invalid use of NULL' error message. How can I get
around this?
thx, in advance
George Papadopoulos
Private Sub Anazhthsh_Click()
Dim strSelect As String
Dim intLoop As Integer
Dim intKwdikos_Episkeyhs As Integer, sum1 As Integer, Totalsum As Integer
Dim dbEPEMBATHS As Database
' Make a connection to the database
Set dbEPEMBATHS = CurrentDb
strSelect = "Select Kwdikos_episkeyhs, Kwdikos_klinikhs,
Kwdikos_mhxanhmatos FROM EPISKEYH WHERE" _
& " (Hmeromhnia >= #" & Me.From_Date & "#)" _
& " and (Hmeromhnia <= #" & Me.To_Date & "#)" _
& " and (Aitia_blabhs =" & Me.btnKakh_xrhsh & ")"
'Fill in the list box
[list_Episkeyes].RowSource = strSelect
' Loop through table aggregating each sum
For intLoop = 1 To Me!list_Episkeyes.ListCount - 1
intKwdikos_Episkeyhs = Me!list_Episkeyes.Column(0, intLoop)
strSelect = "Select Sum(Kostos) FROM ANTALLAKTIKA WHERE
Kwdikos_episkeyhs =" & intKwdikos_Episkeyhs
sum1 = dbEPEMBATHS.OpenRecordset(strSelect).Fields(0).Value
Totalsum = Totalsum + sum1
Next intLoop
Me.Oliko_kostos.Value = Totalsum
End Sub
I`m experiencing this problem with the strSelect in the For loop. When the
criterion for the Select statement is not satisfied the OpenRecordset
statement fails with an 'invalid use of NULL' error message. How can I get
around this?
thx, in advance
George Papadopoulos