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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|