A family of Microsoft relational database management systems designed for ease of use.
Thanks Ken!
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi guys,
I need some help here. In addition to my earlier thread http://answers.microsoft.com/en-us/office/forum/office\_2013\_release-access/adding-a-limit-to-insertion-of-data/afdab8c1-bfdf-48b5-914b-56f25264d987
I have a registration Form with the fields StdID (for student ID) and CourseID.
I have a Registration Table with the fields Student ID(with a space inbetween) and CourseID.
I want to limit a unique StudentID from registering for more than 6 courses, so I enter the followin VBA code to my registration form.
Private Sub Form_BeforeInsert(Cancel As Integer)
If (DCount("Student ID", "Registration", "Student ID=" & Me.StdID) = 6) Then
MsgBox "You have reached the limit of courses allowed.", vbExclamation, "Can't Add Another Course"
Cancel = True
End If
End Sub
But I am getting the Error 3075 syntax error(missing operator). May I know what is wrong here?
A family of Microsoft relational database management systems designed for ease of use.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Thanks Ken!
As the column name includes spaces you need to wrap it in square brackets:
If (DCount("[Student ID]", "Registration", "[Student ID]=" & Me.StdID) = 6) Then
While Access allows spaces and other special characters to be used in object names, and Access templates etc often do so, it is nevertheless not best practice. Instead use CamelCase or represent a space by an underscore character Like_This.
As this question is a development of your other thread, it would have been more appropriate to post it there, or at least include a hyperlink to the other thread here.