Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

No More lines to a sub-form!

Status
Not open for further replies.

ShaneBrennan

Programmer
May 19, 1999
198
GB
before I begin THANKS JULIO for the help you gave me earlier today!<br><br>Right, let me begin.<br><br>I have this little database for maintaining the contents of a cupboard - I know a boring program, but this is a small test proggie to ensure I can do a very important part of a project I may be doing.<br><br>I have a form with a sub-form.&nbsp;&nbsp;The mainform displays information about cupboards whilst the sub-form holds information about the boxes in this form.<br><br>On the main form I have two fields.&nbsp;&nbsp;NoOfBoxesInCabinet and MaxNoOfBoxesInCupboard.<br><br>What I want to do is STOP any more additions to the sub-form once the Max number of boxes have been entered.&nbsp;&nbsp;I've spotted an &quot;Allow Additions&quot; on the sub-form.&nbsp;&nbsp;Can I set this via code, if so can anyone help me! <br><br>Or if I'm on the wrong track can someone please steer me on the right one.<br><br>Again thanks for any help you give us.<br> <p> Shane Brennan<br><a href=mailto:brennans@tcat.ac.uk>brennans@tcat.ac.uk</a><br><a href= > </a><br>
 
I have found that trying to change the properies of a form on the fly does not work well or is not very consistant.<br><br>So you have to have a count somehow.<br>say its 100 or the Recordcount of the subform is 100<br>Now if they try to add more records then the Update events on the subform will need code to check the record count and then do something to stop it.<br>---------------- here is code for getting the record count of a subform<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim rst As Recordset <br>&nbsp;&nbsp;&nbsp;&nbsp;Set rst = Me![YourSubForm].Form.RecordsetClone<br>&nbsp;&nbsp;&nbsp;&nbsp;rst.MoveLast<br>&nbsp;&nbsp;&nbsp;&nbsp;rst.MoveFirst<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;if rst.RecordCount =&gt; 100 then<br>&nbsp;&nbsp;&nbsp;&nbsp;MsgBox &quot;cannot add anymore records&quot;, vbExclamation, &quot;No more&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;' do something to get rid of the record<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;end if<br> <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top