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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top