prohibit the entrance of a record

  • Thread starter Thread starter Frank Dulk
  • Start date Start date
F

Frank Dulk

how do I do to prohibit the entrance of a record if it goes of the same
customer and with the smaller date than 30 days?
 
In the BeforeUpdate event of the form, check for the customer and the last
date you made an entry for that customer. If it has been less then 30 days,
Cancel the update and inform the user using a MsgBox.

To lookup the customer, use the DMax function to get the last entry for the
customer.

Example:
dteLastDate = DMax("[DateField]", "[TableName]", "[CustomerID]=" &
Me.txtCustomerID)
If dteLastDate > Date - 30 Then
Cancel = True
MsgBox "You can only make an entry every 30 days!", vbOkOnly +
vbInformation, "Too Soon"
End If
 
Thank you

Wayne Morgan said:
In the BeforeUpdate event of the form, check for the customer and the last
date you made an entry for that customer. If it has been less then 30 days,
Cancel the update and inform the user using a MsgBox.

To lookup the customer, use the DMax function to get the last entry for the
customer.

Example:
dteLastDate = DMax("[DateField]", "[TableName]", "[CustomerID]=" &
Me.txtCustomerID)
If dteLastDate > Date - 30 Then
Cancel = True
MsgBox "You can only make an entry every 30 days!", vbOkOnly +
vbInformation, "Too Soon"
End If

--
Wayne Morgan
MS Access MVP


Frank Dulk said:
how do I do to prohibit the entrance of a record if it goes of the same
customer and with the smaller date than 30 days?
 
Back
Top