Validation Rules?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have two tables, Table of Events and Customer Registration. In Table of
Events there are two fields Date (date/time) and Time (morning/afternoon).
There are only 16 available seats per session, a morning and afternoon
session. Table of events is a subform within the Customer Registration.

How can I set it up so that if someone enters a new appointment for a
customer and the session is full, it will prompt the user to enter the
appointment at later date?

thanks.
 
I have two tables, Table of Events and Customer Registration. In Table of
Events there are two fields Date (date/time) and Time (morning/afternoon).
There are only 16 available seats per session, a morning and afternoon
session. Table of events is a subform within the Customer Registration.

How can I set it up so that if someone enters a new appointment for a
customer and the session is full, it will prompt the user to enter the
appointment at later date?

thanks.

You can't do this with a Validation Rule - such rules are fairly
limited.

You can, however, use the BeforeInsert event of the subform to count
records and issue a warning: e.g.

Private Sub Form_BeforeInsert(Cancel as Integer)
If DCount("*", "[Table of Events]", "[CustomerID] = " _
& Me!CustomerID & " AND [Date] = #" & Me![Date] & "# " _
& " AND [Time] = '" & Me![Time] & "'") >= 16 Then
MsgBox "This session is full, please pick another", vbOKOnly
Cancel = True
End If
End Sub

Note that Date and Time are both reserved words and should NOT be used
as fieldnames!

John W. Vinson[MVP]
 
Back
Top