B
Brennan
I have the following group of code, but I keep getting a "no current record"
error. I realize that there will be instances when there is not a record
that comes up via the SQL, but I need it to just populate a zero (0) value in
that field when it happens. Doesn't the if isnull statement handle that
type of error. If some kind person can check my code and let me know how to
fix it, I would appreciate the help. Thanks all.
Private Sub presaleupdate()
Dim str As String
Dim rs As DAO.Recordset
Dim combo1 As String
Dim db As DAO.Database
combo1 = Me.AccountingPeriod
str = "SELECT Sum([Lent - Postsale].Lentcredit) AS SumOfLentcredit FROM
[Lent - Postsale]GROUP BY [Lent - Postsale].[Cost Summary Period] HAVING
((([Lent - Postsale].[Cost Summary Period])='" & combo1 & "'));"
Set db = CurrentDb
Set rs = db.OpenRecordset(str, dbOpenSnapshot)
If IsNull(rs!SumOfLentcredit.Value) Then
Me.postsalelent1 = "0"
Else
With rs!SumOfLentcredit
Me.postsalelent1 = rs!SumOfLentcredit.Value
End With
End If
rs.Close
db.Close
Exit_Handler:
Exit Sub
Err_Handler:
MsgBox Err.Description & Err.Number
Resume Exit_Handler
End Sub
error. I realize that there will be instances when there is not a record
that comes up via the SQL, but I need it to just populate a zero (0) value in
that field when it happens. Doesn't the if isnull statement handle that
type of error. If some kind person can check my code and let me know how to
fix it, I would appreciate the help. Thanks all.
Private Sub presaleupdate()
Dim str As String
Dim rs As DAO.Recordset
Dim combo1 As String
Dim db As DAO.Database
combo1 = Me.AccountingPeriod
str = "SELECT Sum([Lent - Postsale].Lentcredit) AS SumOfLentcredit FROM
[Lent - Postsale]GROUP BY [Lent - Postsale].[Cost Summary Period] HAVING
((([Lent - Postsale].[Cost Summary Period])='" & combo1 & "'));"
Set db = CurrentDb
Set rs = db.OpenRecordset(str, dbOpenSnapshot)
If IsNull(rs!SumOfLentcredit.Value) Then
Me.postsalelent1 = "0"
Else
With rs!SumOfLentcredit
Me.postsalelent1 = rs!SumOfLentcredit.Value
End With
End If
rs.Close
db.Close
Exit_Handler:
Exit Sub
Err_Handler:
MsgBox Err.Description & Err.Number
Resume Exit_Handler
End Sub