Print Page | Close Window

VBA Question

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=598
Printed Date: 29 March 2026 at 3:39am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: VBA Question
Posted By: hockenpj
Subject: VBA Question
Date Posted: 28 February 2003 at 11:50am

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.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net