Reputation: 1090
I am trying to make a form with two filter buttons. First button will + 1 to the filter and second button will -1 to the filter.
so far I have.
Dim ADD As String
If Me.TypeID Is Empty Then
'empty TypeID, do nothing
Else
ADD = Me.TypeID + 1
DoCmd.ApplyFilter "", "[TypeID] = " & ADD
End If
I am getting
error 2427
because I can't trap if the next TypeID doesn't exist.
For example, I have now 4 records as TypeId. If I add 1, I will have 5 which I don't have.
Thank you.
Upvotes: 1
Views: 443
Reputation: 1090
Find it.
Dim Add As String
Dim LastID As Integer
LastID = DMax("TypeID", "tblType")
If Me.TypeID = LastID Then
'Empty TypeID, Do Nothing...
Else
Add = Me.TypeID + 1
DoCmd.ApplyFilter "", "[TypeID] = " & Add
End If
Upvotes: 1