467,879 Members | 1,366 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,879 developers. It's quick & easy.

Limit Data Entry To Three Records

I have two tables:

TblCourse
CourseID
CourseName

TblClass
ClassID
CourseID
ClassDate

Classes are entered in a subform. How do I limit data entry to a max of 3
classes for any course?

Thanks!

Nancy
Nov 12 '05 #1
  • viewed: 3677
Share:
5 Replies
Try putting this code in the subform's Current event:

if Me.NewRecord then
if Me.RecordsetClone.RecordCount > 2 then
MsgBox "Only three entries allowed."
Me.Recordset.MoveFirst
endif
endif

Pavel

Nancy wrote:

I have two tables:

TblCourse
CourseID
CourseName

TblClass
ClassID
CourseID
ClassDate

Classes are entered in a subform. How do I limit data entry to a max of 3
classes for any course?

Thanks!

Nancy

Nov 12 '05 #2
Pavel,

Thanks for responding!

Your code limits data entry to 3 total records. That's not what I want. I need
to limit data entry to 3 classes for any course. Total records could be well
over 100.

Nancy

"Pavel Romashkin" <pa*************@hotmail.com> wrote in message
news:40***************@hotmail.com...
Try putting this code in the subform's Current event:

if Me.NewRecord then
if Me.RecordsetClone.RecordCount > 2 then
MsgBox "Only three entries allowed."
Me.Recordset.MoveFirst
endif
endif

Pavel

Nancy wrote:

I have two tables:

TblCourse
CourseID
CourseName

TblClass
ClassID
CourseID
ClassDate

Classes are entered in a subform. How do I limit data entry to a max of 3
classes for any course?

Thanks!

Nancy

Nov 12 '05 #3
if it is only ever going to be up to three classes then it would be easier
to make the two tables into one with fields like

class
etc...
"Nancy" <nf****@earthlink.net> wrote in message
news:8L******************@newsread2.news.atl.earth link.net...
I have two tables:

TblCourse
CourseID
CourseName

TblClass
ClassID
CourseID
ClassDate

Classes are entered in a subform. How do I limit data entry to a max of 3
classes for any course?

Thanks!

Nancy

---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.687 / Virus Database: 448 - Release Date: 16/05/2004
---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.687 / Virus Database: 448 - Release Date: 16/05/2004
Nov 12 '05 #4
TC
He presumeably assumed that the subform was displaying the classes for the
course selected in the main form.

TC
"Nancy" <nf****@earthlink.net> wrote in message
news:SW*******************@newsread2.news.atl.eart hlink.net...
Pavel,

Thanks for responding!

Your code limits data entry to 3 total records. That's not what I want. I need to limit data entry to 3 classes for any course. Total records could be well over 100.

Nancy

"Pavel Romashkin" <pa*************@hotmail.com> wrote in message
news:40***************@hotmail.com...
Try putting this code in the subform's Current event:

if Me.NewRecord then
if Me.RecordsetClone.RecordCount > 2 then
MsgBox "Only three entries allowed."
Me.Recordset.MoveFirst
endif
endif

Pavel

Nancy wrote:

I have two tables:

TblCourse
CourseID
CourseName

TblClass
ClassID
CourseID
ClassDate

Classes are entered in a subform. How do I limit data entry to a max of 3 classes for any course?

Thanks!

Nancy


Nov 12 '05 #5
TC is correct. The code I suggested is to be put into the subform module
where you are entering the classes for a given course, where the course
is chosen on the main form and the subform lists the classes for the
given course.
If you have a different design, you may want to use a query to find the
amount of records:

SELECT Count(ClassID) FROM TblClass WHERE CourseID = MyCourseID AND
ClassID = MyClassID

and then use it in any way you want.
Pavel

Nancy wrote:

Pavel,

Thanks for responding!

Your code limits data entry to 3 total records. That's not what I want. I need
to limit data entry to 3 classes for any course. Total records could be well
over 100.

Nancy

"Pavel Romashkin" <pa*************@hotmail.com> wrote in message
news:40***************@hotmail.com...
Try putting this code in the subform's Current event:

if Me.NewRecord then
if Me.RecordsetClone.RecordCount > 2 then
MsgBox "Only three entries allowed."
Me.Recordset.MoveFirst
endif
endif

Pavel

Nancy wrote:

I have two tables:

TblCourse
CourseID
CourseName

TblClass
ClassID
CourseID
ClassDate

Classes are entered in a subform. How do I limit data entry to a max of 3
classes for any course?

Thanks!

Nancy

Nov 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Randell D. | last post: by
1 post views Thread by Trent | last post: by
reply views Thread by MrMoon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.