Code:
Select Case Item
Case = "Toothbrush"
Step 1: lookup the last date that a person was given a toothbrush
Step 1.1 : No date found - never been given one
: Ok to add item
Step 1:2 : is the DateDiff() between Last Date and Today < 30
Step 1.3 : No - Ok to give them one
Step 1.4 : Yes - Warn User with message box about last date issued.
Case else
End Select
In detail
Code:
Dim DtLastIssue As Date
Dim Elapsed As Integer
'What was the last date a person was given a toothbrush?
DtLastIssue = Nz(DMax("[DateIssued]","Inventory","[PrimaryKey]=" ID),0)
Select Case Item
Case "Toothbrush"
'No date found
If DtLastIssue = 0 Then
'Yes they can have a toothbrush
Else
'How many days is it since they were given a brush
Elapsed = DateDiff("d",DtLastIssue,Date)
If Elapsed > 30 Then
'Yes they can have a toothbrush
Else
'No they can't it was issued in the last 30 days
MsgBox "Toothbrush issued on " & DtLastIssued & " (" & Elapsed & " day(s) ago)."
End If
End If
Case Else
End Select