I have some VBA that will make an error message appear if the number in one cell on the form exceeds the number in another cell on the same form. This code looks like this:
----------------------
Private Sub Form_BeforeInsert(Cancel As Integer)
If [Number of Pupils on Course] >= [Parent]![Maximum class size] Then
x = MsgBox("This Course is Full.", vbOKOnly, "Course Full")
DoCmd.CancelEvent
Me.Refresh
End If
End Sub
----------------------
There is nothing wrong with the above code. What I want to do is to display what is in a cell on the form on question in the error message. Is this possible. Below is my attempt at solving this, but I was unsuccessful:
----------------------
Private Sub Form_BeforeInsert(Cancel As Integer)
If [Number of Pupils on Course] >= [Parent]![Maximum class size] Then
x = MsgBox("This Course is Full. The next course is on the =[Parent]![Next Start Date]", vbOKOnly, "Course Full")
DoCmd.CancelEvent
Me.Refresh
End If
End Sub
----------------------
Any suggestions would be much appreciated.
Edited by hockenpj