Re: Validation Rule in Access form



Private Sub Men_BeforeUpdate(Cancel As Integer)
If Me!Men Then
If DCount(1, "zMenTotal") = 15 Then
Cancel = True
MsgBox "This workshop is full."
End If
End If
End Sub

The only field in the query zMenTotal is MenTotal, which is done by
COUNT(Men) AS MenTotal FROM Workshops WHERE Men=True. However, it pulls
from the checkbox Men which is located in table Workshops. The name of
the control in the form is also Men.

.



Relevant Pages

  • Form_Open cancelled "delayed" !?
    ... Private Sub Form_Open ... The IsOkToProceed return false (I added the MsgBox to verify it) and cancel is set to true. ... If I Open the form directly from the database window, it correctly displays the message and return to the datatbase window. ...
    (microsoft.public.access.formscoding)
  • Re: Change Address Fields with Combo on Form
    ... MsgBox "Update Completed" ... Private Sub cmb_Addr_change_AfterUpdate ... Dim SQL_Text As String ... MsgBox "Update canceled by user" ' Cancel update. ...
    (microsoft.public.access.forms)
  • DateTime question - for John W Vinson[MVP]?
    ... Private Sub txtStartDateTime_BeforeUpdate ... MsgBox "Date must be later that midnight last Wednesday", ... Cancel = True ... If you insist on having two fields, you must add txtStartDate to ...
    (microsoft.public.access.formscoding)
  • Re: Cancel = True still letting user exit
    ... Private Sub PrintBehReptBut_Click ... If mOKToClose Eqv False Then ... MsgBox "You must fix the current record before closing the form." ... Cancel = True ...
    (microsoft.public.access.forms)
  • Re: Form_Open cancelled "delayed" !?
    ... I believe that this is due to the fact that Microsoft has tried to make the ... Private Sub Form_Open ... MsgBox "Can't use this form now - Open canceled" ... cancel is set to true. ...
    (microsoft.public.access.formscoding)