Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / July 2007

Tip: Looking for answers? Try searching our database.

Limiting subform entries based on mainform field value

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Anika V. Bristalli - 09 Jul 2007 16:40 GMT
Hi,

I am sure that someone has already asked (and got an answer) to my
question, but I was not able to find the exact answer by searching
through the previous topics. Big part of it is probably the fact that
I am fairly new to Access, and probably was not searching for the
right key words. But at any rate, here is my question.

I am trying to build a form (with a subform) that allows consultants
within a company to record their client consultations. So, here are
the details.

I have a mainform with the following fields:
Clients (ClientID, Client Name),
Client's membership status (Status)
Number of days of consulting (ConsultNo)

The membership status determines the number of days of consulting, but
both fields are present on the form for reference.

I also have a subform, which is based on a table of records of actual
consulting appointments for each client. This subform includes the
following fields:
Date
Consultant Name
Subject

What I am trying to figure out is how to limit the number of entries
per client (which is in the subform) based on teh number of consulting
appointments available to them (which is in the main form). So, in
general, I am trying to figure out how to limit a number of particular
entries in a subform. Note: I am not trying to limit the total number
of entries in the subform table.

I am not sure whether this description captures what I am trying to
do, but I would really appreciate any tips or suggestions.

Thank you very much in advance!
Allen Browne - 09 Jul 2007 16:55 GMT
Use the BeforeInsert event procedure of the subform.
Cancel the event if there are already the full number of records.

You could get the number of records from the subform with:
   Me.RecordsetClone.RecordCount
But that would not work if the subform were filtered, so it might be better
to use:
   DCount("*", "MySubformTable", "MyForeignID = " & Nz(Me.Parent![ID],0))

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

> Hi,
>
[quoted text clipped - 34 lines]
>
> Thank you very much in advance!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.