G
Guest
Hello,
I seem to be having a problem with my events. I turn them off in code to
process things but I have lost it somewhere... I have set up a watch on
application.enableevents and it breaks on this function...
It breaks on the first line...with events being off but this function does
not turn them off... I cannot figure it out. Any change events can be turned
off some other way? I have searched the code and no where... Please help...
Thanks,
Ernst.
Function CountDaysWithSales(dEnd As Date) As Integer
' ********************************************************
' ** Count Database records with Sales
' ** dEnd - Date of Week Ending Date
' ********************************************************
Dim fld As Field
Dim rst As ADODB.Recordset
Dim sConn As String
Dim sSQL As String
Dim dLast As Date
On Error GoTo ErrHandler
CountDaysWithSales = 0
sFile = ThisWorkbook.Path & DB_FILE
dLast = DateSerial(Year(dEnd), Month(dEnd) + 1, 0) + 1
' Create a new recordset object
Set rst = New ADODB.Recordset
' Connection details
sConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sFile
'Verify a record
sSQL = "SELECT COUNT([ID]) FROM " & DAY_TABLE & _
" WHERE [Daily Sales]>0 AND Date<#" & dLast & "# " & _
"AND Date>#" & dEnd & "#;"
rst.Open sSQL, sConn
If rst.State = adStateOpen Then
CountDaysWithSales = rst.Fields(0).Value
End If
Done:
rst.Close
Set rst = Nothing
Exit Function
ErrHandler:
CountDaysWithSales = 0
Resume Done
End Function
I seem to be having a problem with my events. I turn them off in code to
process things but I have lost it somewhere... I have set up a watch on
application.enableevents and it breaks on this function...
It breaks on the first line...with events being off but this function does
not turn them off... I cannot figure it out. Any change events can be turned
off some other way? I have searched the code and no where... Please help...
Thanks,
Ernst.
Function CountDaysWithSales(dEnd As Date) As Integer
' ********************************************************
' ** Count Database records with Sales
' ** dEnd - Date of Week Ending Date
' ********************************************************
Dim fld As Field
Dim rst As ADODB.Recordset
Dim sConn As String
Dim sSQL As String
Dim dLast As Date
On Error GoTo ErrHandler
CountDaysWithSales = 0
sFile = ThisWorkbook.Path & DB_FILE
dLast = DateSerial(Year(dEnd), Month(dEnd) + 1, 0) + 1
' Create a new recordset object
Set rst = New ADODB.Recordset
' Connection details
sConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sFile
'Verify a record
sSQL = "SELECT COUNT([ID]) FROM " & DAY_TABLE & _
" WHERE [Daily Sales]>0 AND Date<#" & dLast & "# " & _
"AND Date>#" & dEnd & "#;"
rst.Open sSQL, sConn
If rst.State = adStateOpen Then
CountDaysWithSales = rst.Fields(0).Value
End If
Done:
rst.Close
Set rst = Nothing
Exit Function
ErrHandler:
CountDaysWithSales = 0
Resume Done
End Function