A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Limit rows in subform based on field in main form



 
 
Thread Tools Display Modes
  #1  
Old March 3rd, 2010, 12:50 AM posted to microsoft.public.access.forms
cynteeuh
external usenet poster
 
Posts: 31
Default Limit rows in subform based on field in main form

I have a main form that has a number field (this field inidcates the number
of seats available). I want the subform to only allow the user to enter data
in rows that are equal or less than than the number field in the main form.

please help with code and best place to enter.

many thanks!!!
  #2  
Old March 3rd, 2010, 03:09 AM posted to microsoft.public.access.forms
PieterLinden via AccessMonster.com
external usenet poster
 
Posts: 307
Default Limit rows in subform based on field in main form

cynteeuh wrote:
I have a main form that has a number field (this field inidcates the number
of seats available). I want the subform to only allow the user to enter data
in rows that are equal or less than than the number field in the main form.

please help with code and best place to enter.

many thanks!!!


You need to use a RecordsetClone to get the count of records in the subform.
Then in the BeforeInsert event, check that

If RecordsetClone.RecordCountMAX_CHILD_RECORDS Then
'MsgBox...
Cancel = True
End If

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201003/1

  #3  
Old March 3rd, 2010, 03:16 AM posted to microsoft.public.access.forms
Tom van Stiphout[_2_]
external usenet poster
 
Posts: 1,653
Default Limit rows in subform based on field in main form

On Tue, 2 Mar 2010 15:50:01 -0800, cynteeuh
wrote:

In some subforms users can sort the data differently, so just making
the top N rows editable is not going to be good enough. How will we
know which rows you mean?

In general terms you can write code in the subform's Form_Current
event and set Me.AllowEdits to True or False based on if it's in the
first N rows or not.
Me.RecordsetClone.AbsolutePosition can be used to get the 0-based row
count.

-Tom.
Microsoft Access MVP


I have a main form that has a number field (this field inidcates the number
of seats available). I want the subform to only allow the user to enter data
in rows that are equal or less than than the number field in the main form.

please help with code and best place to enter.

many thanks!!!

  #4  
Old March 3rd, 2010, 03:18 AM posted to microsoft.public.access.forms
Tom van Stiphout[_2_]
external usenet poster
 
Posts: 1,653
Default Limit rows in subform based on field in main form

On Wed, 03 Mar 2010 02:09:55 GMT, "PieterLinden via AccessMonster.com"
u49887@uwe wrote:

Interesting. I took his question to mean: I may have more than N
records, and the user can only enter data in the first N ones.
You took it to mean: I want to prevent the user from entering more
than N rows.

-Tom.
Microsoft Access MVP


cynteeuh wrote:
I have a main form that has a number field (this field inidcates the number
of seats available). I want the subform to only allow the user to enter data
in rows that are equal or less than than the number field in the main form.

please help with code and best place to enter.

many thanks!!!


You need to use a RecordsetClone to get the count of records in the subform.
Then in the BeforeInsert event, check that

If RecordsetClone.RecordCountMAX_CHILD_RECORDS Then
'MsgBox...
Cancel = True
End If

  #5  
Old March 3rd, 2010, 05:55 AM posted to microsoft.public.access.forms
PieterLinden via AccessMonster.com
external usenet poster
 
Posts: 307
Default Limit rows in subform based on field in main form

Tom van Stiphout wrote:
Interesting. I took his question to mean: I may have more than N
records, and the user can only enter data in the first N ones.
You took it to mean: I want to prevent the user from entering more
than N rows.

-Tom.
Microsoft Access MVP


That's what I thought the poster meant... only because nothing else made
sense. Maybe I'm wrong...

--
Message posted via http://www.accessmonster.com

  #6  
Old May 25th, 2010, 08:13 PM posted to microsoft.public.access.forms
cynteeuh
external usenet poster
 
Posts: 31
Default Limit rows in subform based on field in main form

Pieter is correct in what I meant. Sorry for any confusion. I'll definitely
give this a try.

Thank you!!!

"PieterLinden via AccessMonster.com" wrote:

Tom van Stiphout wrote:
Interesting. I took his question to mean: I may have more than N
records, and the user can only enter data in the first N ones.
You took it to mean: I want to prevent the user from entering more
than N rows.

-Tom.
Microsoft Access MVP


That's what I thought the poster meant... only because nothing else made
sense. Maybe I'm wrong...

--
Message posted via http://www.accessmonster.com

.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:22 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.