The below code is not giving me the desired result. I am trying to
compare the same field on two seperate records. One being the current
record, the other being the day before. The code works to a degree,
but the "lngcompare" keeps resulting in 0. I am not getting the field
data from the recordset. Any thoughts?
Private Sub BOILER_1_GAS_METER_BeforeUpdate(Cancel As Integer)
Dim rs As Recordset
Dim lngcompare As Long
Dim strmsg As String
Dim msg, style, title, respose
msg = "Please enter a value greater " & vbCrLf & "than previous value
of " & lngcompare & "."
style = vbOKOnly
title = "Invalid Entry"
Set rs = Me.RecordsetClone
With rs
.MoveNext
lngcompare = ![boiler 1 gas meter]
End With
If Me.BOILER_1_GAS_METER < lngcompare Then
Response = MsgBox(msg, style, title)
If Response = vbOK Then
Cancel = True
End If
End If
rs.Close
Set re = Nothing
End Sub